Zelda Classic Coverage Report


Directory: src/
File: src/qst.cpp
Date: 2023-03-18 18:24:01
Exec Total Coverage
Lines: 7984 12188 65.5%
Functions: 69 106 65.1%
Branches: 4985 9899 50.4%

Line Branch Exec Source
1 //--------------------------------------------------------
2 // Zelda Classic
3 // by Jeremy Craner, 1999-2000
4 //
5 // qst.cc
6 //
7 // Code for loading '.qst' files in ZC and ZQuest.
8 //
9 //--------------------------------------------------------
10
11 #ifndef __GTHREAD_HIDE_WIN32API
12 #define __GTHREAD_HIDE_WIN32API 1
13 #endif //prevent indirectly including windows.h
14
15 #include "precompiled.h" //always first
16
17
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 #include <stdio.h>
18 #include <string.h>
19 #include <string>
20 #include <map>
21 #include <vector>
22 #include <assert.h>
23 #include <fmt/format.h>
24
25
26 #include "metadata/sigs/devsig.h.sig"
27 #include "metadata/sigs/compilersig.h.sig"
28 #include "metadata/versionsig.h"
29 #include "base/zc_alleg.h"
30 #include "base/zdefs.h"
31 #include "base/colors.h"
32 #include "tiles.h"
33 #include "base/zsys.h"
34 #include "qst.h"
35 //#include "zquest.h"
36 #include "defdata.h"
37 #include "subscr.h"
38 #include "font.h"
39 #include "zc_custom.h"
40 #include "sfx.h"
41 #include "md5.h"
42 #include "ffscript.h"
43 #include "particles.h"
44 #include "dialog/alert.h"
45 //FFScript FFCore;
46 extern FFScript FFCore;
47 extern ZModule zcm;
48 extern zcmodule moduledata;
49 extern uint8_t __isZQuest;
50 extern sprite_list guys, items, Ewpns, Lwpns, Sitems, chainlinks, decorations;
51 extern particle_list particles;
52 extern void setZScriptVersion(int32_t s_version);
53 //FFSCript FFEngine;
54
55 int32_t temp_ffscript_version = 0;
56 static bool read_ext_zinfo = false, read_zinfo = false;
57 static bool loadquest_report = false;
58 static char const* loading_qst_name = NULL;
59 static byte loading_qst_num = 0;
60
61 #ifdef _MSC_VER
62 #define strncasecmp _strnicmp
63 #endif
64
65 #ifndef _AL_MALLOC
66 #define _AL_MALLOC(a) _al_malloc(a)
67 #define _AL_FREE(a) _al_free(a)
68 #endif
69
70 using std::string;
71 using std::pair;
72
73 // extern bool debug;
74 extern int32_t hero_animation_speed; //lower is faster animation
75 extern std::vector<mapscr> TheMaps;
76 extern zcmap *ZCMaps;
77 extern MsgStr *MsgStrings;
78 extern DoorComboSet *DoorComboSets;
79 extern dmap *DMaps;
80 extern newcombo *combobuf;
81 extern byte *colordata;
82 //extern byte *tilebuf;
83 extern tiledata *newtilebuf;
84 extern byte *trashbuf;
85 extern itemdata *itemsbuf;
86 extern wpndata *wpnsbuf;
87 extern comboclass *combo_class_buf;
88 extern guydata *guysbuf;
89 extern ZCHEATS zcheats;
90 extern zinitdata zinit;
91 extern char palnames[MAXLEVELS][17];
92 extern int32_t memrequested;
93 extern char *byte_conversion(int32_t number, int32_t format);
94 extern char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2);
95 29 string zScript;
96 29 std::map<int32_t, script_slot_data > ffcmap;
97 29 std::map<int32_t, script_slot_data > globalmap;
98 29 std::map<int32_t, script_slot_data > genericmap;
99 29 std::map<int32_t, script_slot_data > itemmap;
100 29 std::map<int32_t, script_slot_data > npcmap;
101
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
29 std::map<int32_t, script_slot_data > ewpnmap;
102 29 std::map<int32_t, script_slot_data > lwpnmap;
103 29 std::map<int32_t, script_slot_data > playermap;
104 29 std::map<int32_t, script_slot_data > dmapmap;
105 29 std::map<int32_t, script_slot_data > screenmap;
106 29 std::map<int32_t, script_slot_data > itemspritemap;
107 29 std::map<int32_t, script_slot_data > comboscriptmap;
108 void free_newtilebuf();
109 bool combosread=false;
110 bool mapsread=false;
111 bool fixffcs=false;
112 bool fixpolsvoice=false;
113
114
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 const std::string script_slot_data::DEFAULT_FORMAT = "%s %s";
115
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 const std::string script_slot_data::INVALID_FORMAT = "%s --%s";
116
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 const std::string script_slot_data::DISASSEMBLED_FORMAT = "%s ++%s";
117
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 const std::string script_slot_data::ZASM_FORMAT = "%s ==%s";
118
119 char qstdat_string[2048] = { 0 };
120
121 static zinfo* load_tmp_zi = NULL;
122
123 int32_t memDBGwatch[8]= {0,0,0,0,0,0,0,0}; //So I can monitor memory crap
124 const byte clavio[9]={97,109,111,110,103,117,115,0};
125
126 //enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
127 // qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
128
129 extern combo_alias combo_aliases[MAXCOMBOALIASES];
130 extern combo_pool combo_pools[MAXCOMBOPOOLS];
131 const char *qst_error[] =
132 {
133 "OK","File not found","Invalid quest file",
134 "Version not supported","Obsolete version",
135 "Missing new data" , /* but let it pass in ZQuest */
136 "Internal error occurred", "Invalid password",
137 "Doesn't match saved game", "Save file is for older version of quest; please start new save",
138 "Out of memory", "File Debug Mode", "Canceled", "", "No quest assigned"
139 };
140
141 //for legacy quests -DD
142 enum { ssiBOMB, ssiSWORD, ssiSHIELD, ssiCANDLE, ssiLETTER, ssiPOTION, ssiLETTERPOTION, ssiBOW, ssiARROW, ssiBOWANDARROW, ssiBAIT, ssiRING, ssiBRACELET, ssiMAP,
143 ssiCOMPASS, ssiBOSSKEY, ssiMAGICKEY, ssiBRANG, ssiWAND, ssiRAFT, ssiLADDER, ssiWHISTLE, ssiBOOK, ssiWALLET, ssiSBOMB, ssiHCPIECE, ssiAMULET, ssiFLIPPERS,
144 ssiHOOKSHOT, ssiLENS, ssiHAMMER, ssiBOOTS, ssiDINSFIRE, ssiFARORESWIND, ssiNAYRUSLOVE, ssiQUIVER, ssiBOMBBAG, ssiCBYRNA, ssiROCS, ssiHOVERBOOTS,
145 ssiSPINSCROLL, ssiCROSSSCROLL, ssiQUAKESCROLL, ssiWHISPRING, ssiCHARGERING, ssiPERILSCROLL, ssiWEALTHMEDAL, ssiHEARTRING, ssiMAGICRING, ssiSPINSCROLL2,
146 ssiQUAKESCROLL2, ssiAGONY, ssiSTOMPBOOTS, ssiWHIMSICALRING, ssiPERILRING, ssiMAX
147 };
148
149 static byte deprecated_rules[QUESTRULES_NEW_SIZE];
150
151
152 void delete_combo_aliases()
153 {
154 for(int32_t j(0); j<256; j++)
155 {
156 if(combo_aliases[j].combos != NULL)
157 {
158 delete[] combo_aliases[j].combos;
159 combo_aliases[j].combos=NULL;
160 }
161
162 if(combo_aliases[j].csets != NULL)
163 {
164 delete[] combo_aliases[j].csets;
165 combo_aliases[j].csets=NULL;
166 }
167 }
168
169 }
170
171 char *byte_conversion(int32_t number, int32_t format)
172 {
173 static char num_str[40];
174
175 if(format==-1) //auto
176 {
177 format=1; //bytes
178
179 if(number>1024)
180 {
181 format=2; //kilobytes
182 }
183
184 if(number>1024*1024)
185 {
186 format=3; //megabytes
187 }
188
189 if(number>1024*1024*1024)
190 {
191 format=4; //gigabytes (dude, what are you doing?)
192 }
193 }
194
195 switch(format)
196 {
197 case 1: //bytes
198 sprintf(num_str,"%db",number);
199 break;
200
201 case 2: //kilobytes
202 sprintf(num_str,"%.2fk",float(number)/1024);
203 break;
204
205 case 3: //megabytes
206 sprintf(num_str,"%.2fM",float(number)/(1024*1024));
207 break;
208
209 case 4: //gigabytes
210 sprintf(num_str,"%.2fG",float(number)/(1024*1024*1024));
211 break;
212
213 default:
214 exit(1);
215 break;
216 }
217
218 return num_str;
219 }
220
221 406 char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2)
222 {
223 static char num_str1[40];
224 static char num_str2[40];
225 static char num_str[80];
226
227
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 406 times.
406 if(format1==-1) //auto
228 {
229 406 format1=1; //bytes
230
231
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 406 times.
406 if(number1>1024)
232 {
233 406 format1=2; //kilobytes
234 406 }
235
236
2/2
✓ Branch 0 taken 290 times.
✓ Branch 1 taken 116 times.
406 if(number1>1024*1024)
237 {
238 116 format1=3; //megabytes
239 116 }
240
241
1/2
✓ Branch 0 taken 406 times.
✗ Branch 1 not taken.
406 if(number1>1024*1024*1024)
242 {
243 format1=4; //gigabytes (dude, what are you doing?)
244 }
245 406 }
246
247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 406 times.
406 if(format2==-1) //auto
248 {
249 406 format2=1; //bytes
250
251
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 406 times.
406 if(number2>1024)
252 {
253 406 format2=2; //kilobytes
254 406 }
255
256
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 377 times.
406 if(number2>1024*1024)
257 {
258 377 format2=3; //megabytes
259 377 }
260
261
1/2
✓ Branch 0 taken 406 times.
✗ Branch 1 not taken.
406 if(number2>1024*1024*1024)
262 {
263 format2=4; //gigabytes (dude, what are you doing?)
264 }
265 406 }
266
267
2/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 290 times.
✓ Branch 3 taken 116 times.
✗ Branch 4 not taken.
406 switch(format1)
268 {
269 case 1: //bytes
270 sprintf(num_str1,"%db",number1);
271 break;
272
273 case 2: //kilobytes
274 290 sprintf(num_str1,"%.2fk",float(number1)/1024);
275 290 break;
276
277 case 3: //megabytes
278 116 sprintf(num_str1,"%.2fM",float(number1)/(1024*1024));
279 116 break;
280
281 case 4: //gigabytes
282 sprintf(num_str1,"%.2fG",float(number1)/(1024*1024*1024));
283 break;
284
285 default:
286 exit(1);
287 break;
288 }
289
290
2/5
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 377 times.
✗ Branch 4 not taken.
406 switch(format2)
291 {
292 case 1: //bytes
293 sprintf(num_str2,"%db",number2);
294 break;
295
296 case 2: //kilobytes
297 29 sprintf(num_str2,"%.2fk",float(number2)/1024);
298 29 break;
299
300 case 3: //megabytes
301 377 sprintf(num_str2,"%.2fM",float(number2)/(1024*1024));
302 377 break;
303
304 case 4: //gigabytes
305 sprintf(num_str2,"%.2fG",float(number2)/(1024*1024*1024));
306 break;
307
308 default:
309 exit(1);
310 break;
311 }
312
313 406 sprintf(num_str, "%s/%s", num_str1, num_str2);
314 406 return num_str;
315 }
316
317 char *ordinal(int32_t num)
318 {
319 static const char *ending[4] = {"st","nd","rd","th"};
320 static char ord_str[8];
321
322 char *end;
323 int32_t t=(num%100)/10;
324 int32_t n=num%10;
325
326 if(n>=1 && n<4 && t!=1)
327 end = (char *)ending[n-1];
328 else
329 end = (char *)ending[3];
330
331 sprintf(ord_str,"%d%s",num%10000,end);
332 return ord_str;
333 }
334
335 29 int32_t get_version_and_build(PACKFILE *f, word *version, word *build)
336 {
337 int32_t ret;
338 29 *version=0;
339 29 *build=0;
340 29 byte temp_map_count=map_count;
341 byte temp_midi_flags[MIDIFLAGS_SIZE];
342 29 memcpy(temp_midi_flags, midi_flags, MIDIFLAGS_SIZE);
343
344 zquestheader tempheader;
345
346
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!f)
347 {
348 return qe_invalid;
349 }
350
351 29 ret=readheader(f, &tempheader, true);
352
353
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(ret)
354 {
355 return ret;
356 }
357
358 29 map_count=temp_map_count;
359 29 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
360 29 *version=tempheader.zelda_version;
361 29 *build=tempheader.build;
362 29 return 0;
363 29 }
364
365
366 29 bool find_section(PACKFILE *f, int32_t section_id_requested)
367 {
368
369
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!f)
370 {
371 return false;
372 }
373
374 int32_t section_id_read;
375 29 bool catchup=false;
376 word dummy;
377 byte tempbyte;
378 char tempbuf[65536];
379
380
381
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 switch(section_id_requested)
382 {
383 case ID_RULES:
384 case ID_STRINGS:
385 case ID_MISC:
386 case ID_TILES:
387 case ID_COMBOS:
388 case ID_CSETS:
389 case ID_MAPS:
390 case ID_DMAPS:
391 case ID_DOORS:
392 case ID_ITEMS:
393 case ID_WEAPONS:
394 case ID_COLORS:
395 case ID_ICONS:
396 case ID_INITDATA:
397 case ID_GUYS:
398 case ID_MIDIS:
399 case ID_CHEATS:
400 29 break;
401
402 default:
403 al_trace("Bad section requested!\n");
404 return false;
405 break;
406 }
407
408 dword section_size;
409
410 //section id
411
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_mgetl(&section_id_read,f,true))
412 {
413 return false;
414 }
415
416
1/2
✓ Branch 0 taken 5916 times.
✗ Branch 1 not taken.
5916 while(!pack_feof(f))
417 {
418
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 5887 times.
5916 switch(section_id_read)
419 {
420 case ID_RULES:
421 case ID_STRINGS:
422 case ID_MISC:
423 case ID_TILES:
424 case ID_COMBOS:
425 case ID_CSETS:
426 case ID_MAPS:
427 case ID_DMAPS:
428 case ID_DOORS:
429 case ID_ITEMS:
430 case ID_WEAPONS:
431 case ID_COLORS:
432 case ID_ICONS:
433 case ID_INITDATA:
434 case ID_GUYS:
435 case ID_MIDIS:
436 case ID_CHEATS:
437 29 catchup=false;
438 29 break;
439
440 default:
441 5887 break;
442 }
443
444
445
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5916 times.
5916 while(catchup)
446 {
447 //section id
448 section_id_read=(section_id_read<<8);
449
450 if(!p_getc(&tempbyte,f,true))
451 {
452 return false;
453 }
454
455 section_id_read+=tempbyte;
456 }
457
458
1/2
✓ Branch 0 taken 5916 times.
✗ Branch 1 not taken.
5916 if(section_id_read==section_id_requested)
459 {
460 return true;
461 }
462 else
463 {
464 //section version info
465
1/2
✓ Branch 0 taken 5916 times.
✗ Branch 1 not taken.
5916 if(!p_igetw(&dummy,f,true))
466 {
467 return false;
468 }
469
470
1/2
✓ Branch 0 taken 5916 times.
✗ Branch 1 not taken.
5916 if(!p_igetw(&dummy,f,true))
471 {
472 return false;
473 }
474
475 //section size
476
1/2
✓ Branch 0 taken 5916 times.
✗ Branch 1 not taken.
5916 if(!p_igetl(&section_size,f,true))
477 {
478 return false;
479 }
480
481 //pack_fseek(f, section_size);
482
2/2
✓ Branch 0 taken 1900515 times.
✓ Branch 1 taken 5916 times.
1906431 while(section_size>65535)
483 {
484 1900515 pfread(tempbuf,65535,f,true);
485 1900515 tempbuf[65535]=0;
486 1900515 section_size-=65535;
487 }
488
489
2/2
✓ Branch 0 taken 5771 times.
✓ Branch 1 taken 145 times.
5916 if(section_size>0)
490 {
491 145 pfread(tempbuf,section_size,f,true);
492 145 tempbuf[section_size]=0;
493 145 }
494 }
495
496 //section id
497
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 5887 times.
5916 if(!p_mgetl(&section_id_read,f,true))
498 {
499 29 return false;
500 }
501 }
502
503 return false;
504 29 }
505
506
507
508
509
510 29 bool valid_zqt(PACKFILE *f)
511 {
512
513 //word tiles_used;
514 //word combos_used;
515 //open the file
516 //PACKFILE *f = pack_fopen(path, F_READ_PACKED);
517
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(!f)
518 return false;
519
520 //for now, everything else is valid
521 29 return true;
522
523 /*int16_t version;
524 byte build;
525
526 //read the version and make sure it worked
527 if(!p_igetw(&version,f,true))
528 {
529 goto error;
530 }
531
532 //read the build and make sure it worked
533 if(!p_getc(&build,f,true))
534 goto error;
535
536 //read the tile info and make sure it worked
537 if(!p_igetw(&tiles_used,f,true))
538 {
539 goto error;
540 }
541
542 for (int32_t i=0; i<tiles_used; i++)
543 {
544 if(!pfread(trashbuf,tilesize(tf4Bit),f,true))
545 {
546 goto error;
547 }
548 }
549
550 //read the combo info and make sure it worked
551 if(!p_igetw(&combos_used,f,true))
552 {
553 goto error;
554 }
555 for (int32_t i=0; i<combos_used; i++)
556 {
557 if(!pfread(trashbuf,sizeof(newcombo),f,true))
558 {
559 goto error;
560 }
561 }
562
563 //read the palette info and make sure it worked
564 for (int32_t i=0; i<48; i++)
565 {
566 if(!pfread(trashbuf,newpdTOTAL,f,true))
567 {
568 goto error;
569 }
570 }
571 if(!pfread(trashbuf,sizeof(palcycle)*256*3,f,true))
572 {
573 goto error;
574 }
575 for (int32_t i=0; i<MAXLEVELS; i++)
576 {
577 if(!pfread(trashbuf,PALNAMESIZE,f,true))
578 {
579 goto error;
580 }
581 }
582
583 //read the sprite info and make sure it worked
584 for (int32_t i=0; i<MAXITEMS; i++)
585 {
586 if(!pfread(trashbuf,sizeof(itemdata),f,true))
587 {
588 goto error;
589 }
590 }
591
592 for (int32_t i=0; i<MAXWPNS; i++)
593 {
594 if(!pfread(trashbuf,sizeof(wpndata),f,true))
595 {
596 goto error;
597 }
598 }
599
600 //read the triforce pieces info and make sure it worked
601 for (int32_t i=0; i<8; ++i)
602 {
603 if(!p_getc(&trashbuf,f,true))
604 {
605 goto error;
606 }
607 }
608
609
610
611 //read the game icons info and make sure it worked
612 for (int32_t i=0; i<4; ++i)
613 {
614 if(!p_igetw(&trashbuf,f,true))
615 {
616 goto error;
617 }
618 }
619
620 //read the misc colors info and map styles info and make sure it worked
621 if(!pfread(trashbuf,sizeof(zcolors),f,true))
622 {
623 goto error;
624 }
625
626 //read the template screens and make sure it worked
627 byte num_maps;
628 if(!p_getc(&num_maps,f,true))
629 {
630 goto error;
631 }
632 for (int32_t i=0; i<TEMPLATES; i++)
633 {
634 if(!pfread(trashbuf,sizeof(mapscr),f,true))
635 {
636 goto error;
637 }
638 }
639 if (num_maps>1) //dungeon templates
640 {
641 for (int32_t i=0; i<TEMPLATES; i++)
642 {
643 if(!pfread(trashbuf,sizeof(mapscr),f,true))
644 {
645 goto error;
646 }
647 }
648 }
649
650 //yay! it worked! close the file and say everything was ok.
651 pack_fclose(f);
652 return true;
653
654 error:
655 pack_fclose(f);
656 return false;*/
657 29 }
658
659 bool valid_zqt(const char *filename)
660 {
661 PACKFILE *f=NULL;
662 bool isvalid;
663 char deletefilename[1024];
664 deletefilename[0]=0;
665 int32_t error;
666 f=open_quest_file(&error, filename, deletefilename, true, true,false);
667
668 if(!f)
669 {
670 // setPackfilePassword(NULL);
671 return false;
672 }
673
674 isvalid=valid_zqt(f);
675
676 if(deletefilename[0])
677 {
678 delete_file(deletefilename);
679 }
680
681 // setPackfilePassword(NULL);
682 return isvalid;
683 }
684
685 128 PACKFILE *open_quest_file(int32_t *open_error, const char *filename, char *deletefilename, bool compressed,bool encrypted, bool show_progress)
686 {
687 char tmpfilename[L_tmpnam];
688 128 temp_name(tmpfilename);
689 char percent_done[30];
690 128 int32_t current_method=0;
691
692 PACKFILE *f;
693 128 const char *passwd= encrypted ? datapwd : "";
694
695 // oldquest flag is set when an unencrypted qst file is suspected.
696 128 bool oldquest = false;
697 int32_t ret;
698
699
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(show_progress)
700 {
701 box_start(1, "Loading Quest", lfont, font, true);
702 }
703
704 128 box_out("Loading Quest: ");
705 //if(strncasecmp(filename, "qst.dat", 7)!=0)
706 //int32_t qstdat_str_size = 0;
707 //for ( int32_t q = 0; q < 255; q++ ) //find the length of the string
708 //{
709 // if ( moduledata.datafiles[qst_dat][q] != 0 ) qstdat_str_size++;
710 // else break;
711 //}
712 //if(strncasecmp(filename, moduledata.datafiles[qst_dat], 7)!=0)
713 128 al_trace("Trying to do strncasecmp() when loading a quest\n");
714 128 int32_t qstdat_filename_size = strlen(moduledata.datafiles[qst_dat]);
715 128 al_trace("Filename size of qst.dat file %s is %d.\n", moduledata.datafiles[qst_dat], qstdat_filename_size);
716 //if(strncasecmp(filename, moduledata.datafiles[qst_dat], qstdat_filename_size)!=0)
717
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(strcmp(filename, moduledata.datafiles[qst_dat])!=0)
718 {
719 128 box_out(filename);
720 128 }
721 else
722 {
723 box_out("new quest"); // Or whatever
724 }
725 128 box_out("...");
726 128 box_eol();
727 128 box_eol();
728
729
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(encrypted)
730 {
731 128 box_out("Decrypting...");
732 128 box_save_x();
733 128 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_MAX-1, strstr(filename, ".dat#")!=NULL, passwd);
734
735
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 3 times.
128 if(ret)
736 {
737
1/3
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
3 switch(ret)
738 {
739 case 1:
740 box_out("error.");
741 box_eol();
742 box_end(true);
743 *open_error=qe_notfound;
744 return NULL;
745
746 case 2:
747 box_out("error.");
748 box_eol();
749 box_end(true);
750 *open_error=qe_internal;
751 return NULL;
752 // be sure not to delete tmpfilename now...
753 }
754
755
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(ret==5) //old encryption?
756 {
757 3 current_method++;
758 3 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
759 3 box_out(percent_done);
760 3 box_load_x();
761 3 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_211B9, strstr(filename, ".dat#")!=NULL, passwd);
762 3 }
763
764
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(ret==5) //old encryption?
765 {
766 3 current_method++;
767 3 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
768 3 box_out(percent_done);
769 3 box_load_x();
770 3 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B185, strstr(filename, ".dat#")!=NULL, passwd);
771 3 }
772
773
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(ret==5) //old encryption?
774 {
775 current_method++;
776 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
777 box_out(percent_done);
778 box_load_x();
779 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B105, strstr(filename, ".dat#")!=NULL, passwd);
780 }
781
782
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(ret==5) //old encryption?
783 {
784 current_method++;
785 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
786 box_out(percent_done);
787 box_load_x();
788 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B104, strstr(filename, ".dat#")!=NULL, passwd);
789 }
790
791
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(ret)
792 {
793 oldquest = true;
794 passwd="";
795 }
796 3 }
797
798 128 box_out("okay.");
799 128 box_eol();
800 128 }
801 else
802 {
803 oldquest = true;
804 }
805
806 128 box_out("Opening...");
807
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 f = pack_fopen_password(oldquest ? filename : tmpfilename, compressed ? F_READ_PACKED : F_READ, passwd);
808
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!f)
809 {
810 if((compressed==1)&&(errno==EDOM))
811 {
812 f = pack_fopen_password(oldquest ? filename : tmpfilename, F_READ, passwd);
813 }
814
815 if(!f)
816 {
817 if(!oldquest)
818 {
819 delete_file(tmpfilename);
820 }
821 box_out("error.");
822 box_eol();
823 box_end(true);
824 *open_error=qe_invalid;
825 return NULL;
826 }
827 }
828
829
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(!oldquest)
830 {
831
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(deletefilename)
832 128 sprintf(deletefilename, "%s", tmpfilename);
833 128 }
834
835 128 box_out("okay.");
836 128 box_eol();
837
838 128 return f;
839 128 }
840
841 29 PACKFILE *open_quest_template(zquestheader *Header, char *deletefilename, bool validate)
842 {
843 char *filename;
844 29 PACKFILE *f=NULL;
845 29 int32_t open_error=0;
846 29 deletefilename[0]=0;
847
848 29 strcpy(qstdat_string,moduledata.datafiles[qst_dat]);
849 29 strcat(qstdat_string,"#NESQST_NEW_QST");
850
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(Header->templatepath[0]==0)
851 {
852 29 filename=(char *)malloc(2048);
853 //strcpy(filename, "qst.dat#NESQST_NEW_QST");
854 29 strcpy(filename, qstdat_string);
855 29 }
856 else
857 {
858 filename=Header->templatepath;
859 }
860
861 29 f=open_quest_file(&open_error, filename, deletefilename, true, true,false);
862
863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(Header->templatepath[0]==0)
864 {
865 29 free(filename);
866 29 }
867
868
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!f)
869 {
870 return NULL;
871 }
872
873
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(validate)
874 {
875
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!valid_zqt(f))
876 {
877 jwin_alert("Error","Invalid Quest Template",NULL,NULL,"O&K",NULL,'k',0,lfont);
878 pack_fclose(f);
879
880 //setPackfilePassword(NULL);
881 if(deletefilename[0])
882 {
883 delete_file(deletefilename);
884 }
885
886 return NULL;
887 }
888 29 }
889
890 29 return f;
891 29 }
892
893 29 bool init_section(zquestheader *Header, int32_t section_id, miscQdata *Misc, zctune *tunes, bool validate)
894 {
895 29 combosread=false;
896 29 mapsread=false;
897 29 fixffcs=false;
898
899
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 switch(section_id)
900 {
901 case ID_RULES:
902 case ID_STRINGS:
903 case ID_MISC:
904 case ID_TILES:
905 case ID_COMBOS:
906 case ID_CSETS:
907 case ID_MAPS:
908 case ID_DMAPS:
909 case ID_DOORS:
910 case ID_ITEMS:
911 case ID_WEAPONS:
912 case ID_COLORS:
913 case ID_ICONS:
914 case ID_INITDATA:
915 case ID_GUYS:
916 case ID_MIDIS:
917 case ID_CHEATS:
918 case ID_ITEMDROPSETS:
919 case ID_FAVORITES:
920 29 break;
921
922 default:
923 return false;
924 break;
925 }
926
927 int32_t ret;
928 word version, build;
929 29 PACKFILE *f=NULL;
930
931 char deletefilename[1024];
932 29 deletefilename[0]=0;
933
934 //why is this here?
935 /*
936 if(colordata==NULL)
937 return false;
938 */
939
940 //setPackfilePassword(datapwd);
941 29 f=open_quest_template(Header, deletefilename, validate);
942
943
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(!f) //no file, nothing to delete
944 {
945 // setPackfilePassword(NULL);
946 return false;
947 }
948
949 29 ret=get_version_and_build(f, &version, &build);
950
951
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 29 times.
29 if(ret||(version==0))
952 {
953 pack_fclose(f);
954
955 if(deletefilename[0])
956 {
957 delete_file(deletefilename);
958 }
959
960 // setPackfilePassword(NULL);
961 return false;
962 }
963
964
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(!find_section(f, section_id))
965 {
966 29 al_trace("Can't find section!\n");
967 29 pack_fclose(f);
968
969
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(deletefilename[0])
970 {
971 29 delete_file(deletefilename);
972 29 }
973
974 //setPackfilePassword(NULL);
975 29 return false;
976 }
977
978 switch(section_id)
979 {
980 case ID_RULES:
981 //rules
982 ret=readrules(f, Header, true);
983 break;
984
985 case ID_STRINGS:
986 //strings
987 ret=readstrings(f, Header, true);
988 break;
989
990 case ID_MISC:
991 //misc data
992 ret=readmisc(f, Header, Misc, true);
993 break;
994
995 case ID_TILES:
996 //tiles
997 ret=readtiles(f, newtilebuf, Header, version, build, 0, NEWMAXTILES, true, true);
998 break;
999
1000 case ID_COMBOS:
1001 //combos
1002 clear_combos();
1003 ret=readcombos(f, Header, version, build, 0, MAXCOMBOS, true);
1004 combosread=true;
1005 break;
1006
1007 case ID_COMBOALIASES:
1008 //combos
1009 ret=readcomboaliases(f, Header, version, build, true);
1010 break;
1011
1012 case ID_CSETS:
1013 //color data
1014 ret=readcolordata(f, Misc, version, build, 0, newerpdTOTAL, true);
1015 break;
1016
1017 case ID_MAPS:
1018 //maps
1019 ret=readmaps(f, Header, true);
1020 mapsread=true;
1021 break;
1022
1023 case ID_DMAPS:
1024 //dmaps
1025 ret=readdmaps(f, Header, version, build, 0, MAXDMAPS, true);
1026 break;
1027
1028 case ID_DOORS:
1029 //door combo sets
1030 ret=readdoorcombosets(f, Header, true);
1031 break;
1032
1033 case ID_ITEMS:
1034 //items
1035 ret=readitems(f, version, build, true);
1036 break;
1037
1038 case ID_WEAPONS:
1039 //weapons
1040 ret=readweapons(f, Header, true);
1041 break;
1042
1043 case ID_COLORS:
1044 //misc. colors
1045 ret=readmisccolors(f, Header, Misc, true);
1046 break;
1047
1048 case ID_ICONS:
1049 //game icons
1050 ret=readgameicons(f, Header, Misc, true);
1051 break;
1052
1053 case ID_INITDATA:
1054 //initialization data
1055 ret=readinitdata(f, Header, true);
1056 break;
1057
1058 case ID_GUYS:
1059 //guys
1060 ret=readguys(f, Header, true);
1061 break;
1062
1063 case ID_MIDIS:
1064 //midis
1065 ret=readtunes(f, Header, tunes, true);
1066 break;
1067
1068 case ID_CHEATS:
1069 //cheat codes
1070 ret=readcheatcodes(f, Header, true);
1071 break;
1072
1073 case ID_ITEMDROPSETS:
1074 //item drop sets
1075 // Why is this one commented out?
1076 //ret=readitemdropsets(f, (int32_t)version, (word)build, true);
1077 break;
1078
1079 case ID_FAVORITES:
1080 // favorite combos and aliases
1081 ret=readfavorites(f, version, build, true);
1082 break;
1083
1084 default:
1085 ret=-1;
1086 break;
1087 }
1088
1089 pack_fclose(f);
1090
1091 if(deletefilename[0])
1092 {
1093 delete_file(deletefilename);
1094 }
1095
1096 //setPackfilePassword(NULL);
1097 if(!ret)
1098 {
1099 return true;
1100 }
1101
1102 return false;
1103 29 }
1104
1105 bool init_tiles(bool validate, zquestheader *Header)
1106 {
1107 return init_section(Header, ID_TILES, NULL, NULL, validate);
1108 }
1109
1110 bool init_combos(bool validate, zquestheader *Header)
1111 {
1112 return init_section(Header, ID_COMBOS, NULL, NULL, validate);
1113 }
1114
1115 bool init_colordata(bool validate, zquestheader *Header, miscQdata *Misc)
1116 {
1117 return init_section(Header, ID_CSETS, Misc, NULL, validate);
1118 }
1119
1120 99 void init_spritelists()
1121 {
1122
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 22 times.
99 if(FFCore.quest_format[vZelda] < 0x255)
1123 {
1124 77 guys.setMax(255);
1125 77 items.setMax(255);
1126 77 Ewpns.setMax(255);
1127 77 Lwpns.setMax(255);
1128 77 Sitems.setMax(255);
1129 77 chainlinks.setMax(255);
1130 77 decorations.setMax(255);
1131 77 particles.setMax(255);
1132 77 }
1133 else
1134 {
1135 22 guys.setMax(255);
1136 22 items.setMax(255);
1137 22 Ewpns.setMax(255);
1138 22 Lwpns.setMax(255);
1139 22 Sitems.setMax(255);
1140 22 chainlinks.setMax(255);
1141 22 decorations.setMax(255);
1142 22 particles.setMax(255*((255*4)+1)); //255 per sprite that can use particles; guys, items, ewpns, lwpns, +HERO
1143 }
1144 99 }
1145
1146 29 bool reset_items(bool validate, zquestheader *Header)
1147 {
1148 29 bool ret = init_section(Header, ID_ITEMS, NULL, NULL, validate);
1149
1150 //Ignore this, but don't remove it
1151 /*
1152 if (ret)
1153 for(int32_t i=0; i<MAXITEMS; i++)
1154 {
1155 reset_itembuf(&itemsbuf[i], i);
1156 }
1157 */
1158
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 29 times.
7453 for(int32_t i=0; i<MAXITEMS; i++) reset_itemname(i);
1159
1160 29 return ret;
1161 }
1162
1163 bool reset_guys()
1164 {
1165 // The .dat file's guys definitions are always synchronised with defdata.cpp's - even the tile settings.
1166 init_guys(V_GUYS);
1167 return true;
1168 }
1169
1170 bool reset_wpns(bool validate, zquestheader *Header)
1171 {
1172 bool ret = init_section(Header, ID_WEAPONS, NULL, NULL, validate);
1173
1174 for(int32_t i=0; i<WPNCNT; i++)
1175 reset_weaponname(i);
1176
1177 return ret;
1178 }
1179
1180 bool reset_mapstyles(bool validate, miscQdata *Misc)
1181 {
1182 Misc->colors.blueframe_tile = 20044;
1183 Misc->colors.blueframe_cset = 0;
1184 Misc->colors.triforce_tile = 23461;
1185 Misc->colors.triforce_cset = 1;
1186 Misc->colors.triframe_tile = 18752;
1187 Misc->colors.triframe_cset = 1;
1188 Misc->colors.overworld_map_tile = 16990;
1189 Misc->colors.overworld_map_cset = 2;
1190 Misc->colors.HCpieces_tile = 21160;
1191 Misc->colors.HCpieces_cset = 8;
1192 Misc->colors.dungeon_map_tile = 19651;
1193 Misc->colors.dungeon_map_cset = 8;
1194 return true;
1195 }
1196
1197 bool reset_doorcombosets(bool validate, zquestheader *Header)
1198 {
1199 return init_section(Header, ID_DOORS, NULL, NULL, validate);
1200 }
1201
1202 29 int32_t get_qst_buffers()
1203 {
1204 29 memrequested+=(sizeof(mapscr)*MAPSCRS);
1205 29 Z_message("Allocating map buffer (%s)... ", byte_conversion2(sizeof(mapscr)*MAPSCRS,memrequested,-1, -1));
1206 29 TheMaps.resize(MAPSCRS);
1207
1208
2/2
✓ Branch 0 taken 3944 times.
✓ Branch 1 taken 29 times.
3973 for(int32_t i(0); i<MAPSCRS; i++)
1209 3944 TheMaps[i].zero_memory();
1210
1211 //memset(TheMaps, 0, sizeof(mapscr)*MAPSCRS); //shouldn't need this anymore
1212 29 Z_message("OK\n"); // Allocating map buffer...
1213
1214 29 memrequested+=(sizeof(zcmap)*MAXMAPS2);
1215 29 Z_message("Allocating combo buffer (%s)... ", byte_conversion2(sizeof(zcmap)*MAXMAPS2,memrequested,-1,-1));
1216
1217
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if((ZCMaps=(zcmap*)malloc(sizeof(zcmap)*MAXMAPS2))==NULL)
1218 return 0;
1219
1220 29 Z_message("OK\n");
1221
1222 // Allocating space for all 65535 strings uses up 10.62MB...
1223 // The vast majority of finished quests (and I presume this will be consistent for all time) use < 1000 strings in total.
1224 // (Shoelace's "Hero of Dreams" uses 1415.)
1225 // So let's be a bit generous and allow 4096 initially.
1226 // In the rare event that a quest overshoots this mark, we'll reallocate to the full 65535 later.
1227 // I tested it and it worked without flaw on 6/6/11. - L.
1228 // 2022: bumped from 4096 to 8192 to avoid a bug where the Strings menu shows (None) strings when the list passes
1229 // this threshold. Possibly some bug related to `msglistcache` to being reset?
1230 // See https://discord.com/channels/876899628556091432/992984989073416242
1231 29 msg_strings_size = 8192;
1232 29 memrequested+=(sizeof(MsgStr)*msg_strings_size);
1233 29 Z_message("Allocating string buffer (%s)... ", byte_conversion2(sizeof(MsgStr)*msg_strings_size,memrequested,-1,-1));
1234
1235
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 MsgStrings = new MsgStr[msg_strings_size];
1236
1237 //memset(MsgStrings, 0, sizeof(MsgStr)*msg_strings_size);
1238
2/2
✓ Branch 0 taken 237568 times.
✓ Branch 1 taken 29 times.
237597 for(auto q = 0; q < msg_strings_size; ++q)
1239 {
1240 237568 MsgStrings[q].clear();
1241 237568 }
1242 29 Z_message("OK\n"); // Allocating string buffer...
1243
1244 29 memrequested+=(sizeof(DoorComboSet)*MAXDOORCOMBOSETS);
1245 29 Z_message("Allocating door combo buffer (%s)... ", byte_conversion2(sizeof(DoorComboSet)*MAXDOORCOMBOSETS,memrequested,-1,-1));
1246
1247
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if((DoorComboSets=(DoorComboSet*)malloc(sizeof(DoorComboSet)*MAXDOORCOMBOSETS))==NULL)
1248 return 0;
1249
1250 29 Z_message("OK\n"); // Allocating door combo buffer...
1251
1252 29 memrequested+=(sizeof(dmap)*MAXDMAPS);
1253 29 Z_message("Allocating dmap buffer (%s)... ", byte_conversion2(sizeof(dmap)*MAXDMAPS,memrequested,-1,-1));
1254
1255
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if((DMaps=(dmap*)malloc(sizeof(dmap)*MAXDMAPS))==NULL)
1256 return 0;
1257
1258 29 memset(DMaps, 0, sizeof(dmap)*MAXDMAPS);
1259 29 Z_message("OK\n"); // Allocating dmap buffer...
1260
1261 29 memrequested+=(sizeof(newcombo)*MAXCOMBOS);
1262 29 Z_message("Allocating combo buffer (%s)... ", byte_conversion2(sizeof(newcombo)*MAXCOMBOS,memrequested,-1,-1));
1263
1264
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if((combobuf=(newcombo*)malloc(sizeof(newcombo)*MAXCOMBOS))==NULL)
1265 return 0;
1266
1267 29 memset(combobuf, 0, sizeof(newcombo)*MAXCOMBOS);
1268 29 Z_message("OK\n"); // Allocating combo buffer...
1269
1270 29 memrequested+=(psTOTAL255);
1271 29 Z_message("Allocating color data buffer (%s)... ", byte_conversion2(psTOTAL255,memrequested,-1,-1));
1272
1273
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if((colordata=(byte*)malloc(psTOTAL255))==NULL)
1274 return 0;
1275
1276 29 Z_message("OK\n"); // Allocating color data buffer...
1277
1278 29 memrequested+=(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)));
1279 29 Z_message("Allocating tile buffer (%s)... ", byte_conversion2(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)),memrequested,-1,-1));
1280
1281 29 free_newtilebuf();
1282
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if((newtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1283 return 0;
1284
1285 29 memset(newtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1286 //Z_message("Performed memset on tiles\n");
1287 29 clear_tiles(newtilebuf);
1288 //Z_message("Performed clear_tiles()\n");
1289 29 Z_message("OK\n"); // Allocating tile buffer...
1290
1291
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(is_zquest())
1292 {
1293 memrequested+=(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)));
1294 Z_message("Allocating tile grab buffer (%s)... ", byte_conversion2(NEWMAXTILES*sizeof(tiledata),memrequested,-1,-1));
1295
1296 if((grabtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1297 return 0;
1298
1299 memset(grabtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1300 clear_tiles(grabtilebuf);
1301 Z_message("OK\n"); // Allocating tile grab buffer...
1302 }
1303
1304 29 memrequested+=(100000);
1305 29 Z_message("Allocating trash buffer (%s)... ", byte_conversion2(100000,memrequested,-1,-1));
1306
1307
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if((trashbuf=(byte*)malloc(100000))==NULL)
1308 return 0;
1309
1310 29 Z_message("OK\n"); // Allocating trash buffer...
1311
1312 // Big, ugly band-aid here. Perhaps the most common cause of random crashes
1313 // has been inadvertently accessing itemsbuf[-1]. All such crashes should be
1314 // fixed by ensuring there's actually itemdata there.
1315 // If you change this, be sure to update del_qst_buffers, too.
1316
1317 29 memrequested+=(sizeof(itemdata)*(MAXITEMS+1));
1318 29 Z_message("Allocating item buffer (%s)... ", byte_conversion2(sizeof(itemdata)*(MAXITEMS+1),memrequested,-1,-1));
1319
1320
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if((itemsbuf=(itemdata*)malloc(sizeof(itemdata)*(MAXITEMS+1)))==NULL)
1321 return 0;
1322
1323 29 memset(itemsbuf,0,sizeof(itemdata)*(MAXITEMS+1));
1324 29 itemsbuf++;
1325 29 Z_message("OK\n"); // Allocating item buffer...
1326
1327 29 memrequested+=(sizeof(wpndata)*MAXWPNS);
1328 29 Z_message("Allocating weapon buffer (%s)... ", byte_conversion2(sizeof(wpndata)*MAXWPNS,memrequested,-1,-1));
1329
1330
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if((wpnsbuf=(wpndata*)malloc(sizeof(wpndata)*MAXWPNS))==NULL)
1331 return 0;
1332
1333 29 memset(wpnsbuf,0,sizeof(wpndata)*MAXWPNS);
1334 29 Z_message("OK\n"); // Allocating weapon buffer...
1335
1336 29 memrequested+=(sizeof(guydata)*MAXGUYS);
1337 29 Z_message("Allocating guy buffer (%s)... ", byte_conversion2(sizeof(guydata)*MAXGUYS,memrequested,-1,-1));
1338
1339
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if((guysbuf=(guydata*)malloc(sizeof(guydata)*MAXGUYS))==NULL)
1340 return 0;
1341
1342 29 memset(guysbuf,0,sizeof(guydata)*MAXGUYS);
1343 29 Z_message("OK\n"); // Allocating guy buffer...
1344
1345 29 memrequested+=(sizeof(comboclass)*cMAX);
1346 29 Z_message("Allocating combo class buffer (%s)... ", byte_conversion2(sizeof(comboclass)*cMAX,memrequested,-1,-1));
1347
1348
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if((combo_class_buf=(comboclass*)malloc(sizeof(comboclass)*cMAX))==NULL)
1349 return 0;
1350
1351 29 Z_message("OK\n"); // Allocating combo class buffer...
1352
1353 29 return 1;
1354 29 }
1355
1356
1357 29 void free_newtilebuf()
1358 {
1359
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(newtilebuf)
1360 {
1361 for(int32_t i=0; i<NEWMAXTILES; i++)
1362 if(newtilebuf[i].data)
1363 free(newtilebuf[i].data);
1364
1365 free(newtilebuf);
1366 newtilebuf = 0;
1367 }
1368 29 }
1369
1370 void free_grabtilebuf()
1371 {
1372 if(is_zquest())
1373 {
1374 if(grabtilebuf)
1375 {
1376 for(int32_t i=0; i<NEWMAXTILES; i++)
1377 if(grabtilebuf[i].data) free(grabtilebuf[i].data);
1378
1379 free(grabtilebuf);
1380 grabtilebuf = 0;
1381 }
1382 }
1383 }
1384
1385 void del_qst_buffers()
1386 {
1387 al_trace("Cleaning maps. \n");
1388
1389 if(ZCMaps) free(ZCMaps);
1390
1391 if(MsgStrings) delete[] MsgStrings;
1392
1393 if(DoorComboSets) free(DoorComboSets);
1394
1395 if(DMaps) free(DMaps);
1396
1397 if(combobuf) free(combobuf);
1398
1399 if(colordata) free(colordata);
1400
1401 al_trace("Cleaning tile buffers. \n");
1402 free_newtilebuf();
1403 free_grabtilebuf();
1404
1405 al_trace("Cleaning misc. \n");
1406
1407 if(trashbuf) free(trashbuf);
1408
1409 // See get_qst_buffers
1410 if(itemsbuf)
1411 {
1412 itemsbuf--;
1413 free(itemsbuf);
1414 }
1415
1416 if(wpnsbuf) free(wpnsbuf);
1417
1418 if(guysbuf) free(guysbuf);
1419
1420 if(combo_class_buf) free(combo_class_buf);
1421 }
1422
1423 bool init_palnames()
1424 {
1425 // if(palnames==NULL)
1426 // return false;
1427
1428 for(int32_t x=0; x<MAXLEVELS; x++)
1429 {
1430 switch(x)
1431 {
1432 case 0:
1433 sprintf(palnames[x],"Overworld");
1434 break;
1435
1436 case 10:
1437 sprintf(palnames[x],"Caves");
1438 break;
1439
1440 case 11:
1441 sprintf(palnames[x],"Passageways");
1442 break;
1443
1444 default:
1445 sprintf(palnames[x],"%c",0);
1446 break;
1447 }
1448 }
1449
1450 return true;
1451 }
1452
1453 18953 static void *read_block(PACKFILE *f, int32_t size, int32_t alloc_size, bool keepdata)
1454 {
1455 void *p;
1456
1457
1/2
✓ Branch 0 taken 18953 times.
✗ Branch 1 not taken.
18953 p = _AL_MALLOC(MAX(size, alloc_size));
1458
1459
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18953 times.
18953 if(!p)
1460 {
1461 return NULL;
1462 }
1463
1464
1/2
✓ Branch 0 taken 18953 times.
✗ Branch 1 not taken.
18953 if(!pfread(p,size,f,keepdata))
1465 {
1466 _AL_FREE(p);
1467 return NULL;
1468 }
1469
1470
1/2
✓ Branch 0 taken 18953 times.
✗ Branch 1 not taken.
18953 if(pack_ferror(f))
1471 {
1472 _AL_FREE(p);
1473 return NULL;
1474 }
1475
1476 18953 return p;
1477 18953 }
1478
1479 /* read_midi:
1480 * Reads MIDI data from a datafile (this is not the same thing as the
1481 * standard midi file format).
1482 */
1483
1484 1629 static MIDI *read_midi(PACKFILE *f, bool)
1485 {
1486 MIDI *m;
1487 int32_t c;
1488 1629 int16_t divisions=0;
1489 1629 int32_t len=0;
1490
1491 1629 m = (MIDI*)_AL_MALLOC(sizeof(MIDI));
1492
1493
1/2
✓ Branch 0 taken 1629 times.
✗ Branch 1 not taken.
1629 if(!m)
1494 {
1495 return NULL;
1496 }
1497
1498
2/2
✓ Branch 0 taken 52128 times.
✓ Branch 1 taken 1629 times.
53757 for(c=0; c<MIDI_TRACKS; c++)
1499 {
1500 52128 m->track[c].len = 0;
1501 52128 m->track[c].data = NULL;
1502 52128 }
1503
1504 1629 p_mgetw(&divisions,f,true);
1505 1629 m->divisions=divisions;
1506
1507
2/2
✓ Branch 0 taken 52128 times.
✓ Branch 1 taken 1629 times.
53757 for(c=0; c<MIDI_TRACKS; c++)
1508 {
1509 52128 p_mgetl(&len,f,true);
1510 52128 m->track[c].len=len;
1511
1512
2/2
✓ Branch 0 taken 33175 times.
✓ Branch 1 taken 18953 times.
52128 if(m->track[c].len > 0)
1513 {
1514 18953 m->track[c].data = (byte*)read_block(f, m->track[c].len, 0, true);
1515
1516
1/2
✓ Branch 0 taken 18953 times.
✗ Branch 1 not taken.
18953 if(!m->track[c].data)
1517 {
1518 destroy_midi(m);
1519 return NULL;
1520 }
1521 18953 }
1522 52128 }
1523
1524 LOCK_DATA(m, sizeof(MIDI));
1525
1526
2/2
✓ Branch 0 taken 52128 times.
✓ Branch 1 taken 1629 times.
53757 for(c=0; c<MIDI_TRACKS; c++)
1527 {
1528
2/2
✓ Branch 0 taken 18953 times.
✓ Branch 1 taken 33175 times.
52128 if(m->track[c].data)
1529 {
1530 LOCK_DATA(m->track[c].data, m->track[c].len);
1531 18953 }
1532 52128 }
1533
1534 1629 return m;
1535 1629 }
1536
1537 void clear_combo(int32_t i)
1538 {
1539 combobuf[i].clear();
1540 }
1541
1542 void clear_combos()
1543 {
1544 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
1545 clear_combo(tmpcounter);
1546 }
1547
1548 void pack_combos()
1549 {
1550 int32_t di = 0;
1551
1552 for(int32_t si=0; si<1024; si+=2)
1553 combobuf[di++] = combobuf[si];
1554
1555 for(; di<1024; di++)
1556 clear_combo(di);
1557 }
1558
1559 99 void reset_tunes(zctune *tune)
1560 {
1561
2/2
✓ Branch 0 taken 24948 times.
✓ Branch 1 taken 99 times.
25047 for(int32_t i=0; i<MAXCUSTOMTUNES; i++)
1562 {
1563 24948 tune[i].reset();
1564 24948 }
1565 99 }
1566
1567
1568 /*void reset_midi(zcmidi_ *m)
1569 {
1570 m->title[0]=0;
1571 m->loop=1;
1572 m->volume=144;
1573 m->start=0;
1574 m->loop_start=-1;
1575 m->loop_end=-1;
1576 if(m->midi)
1577 {
1578 destroy_midi(m->midi);
1579 }
1580 m->midi=NULL;
1581 }
1582
1583
1584 void reset_midis(zcmidi_ *m)
1585 {
1586 for(int32_t i=0; i<MAXCUSTOMMIDIS; i++)
1587 {
1588 reset_midi(m+i);
1589 }
1590 }
1591 */
1592
1593 void reset_scr(int32_t scr)
1594 {
1595 /*
1596 byte *di=((byte*)TheMaps)+(scr*sizeof(mapscr));
1597 for(unsigned i=0; i<sizeof(mapscr); i++)
1598 *(di++) = 0;
1599 TheMaps[scr].valid=mVERSION;
1600 */
1601
1602 TheMaps[scr].zero_memory();
1603 //byte *di=((byte*)TheMaps)+(scr*sizeof(mapscr));
1604
1605 for(int32_t i=0; i<6; i++)
1606 {
1607 //these will be uncommented later
1608 //TheMaps[scr].layerxsize[i]=16;
1609 //TheMaps[scr].layerysize[i]=11;
1610 TheMaps[scr].layeropacity[i]=255;
1611 }
1612
1613 TheMaps[scr].valid=mVERSION;
1614
1615 }
1616
1617 /* For reference:
1618
1619 enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
1620 qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
1621 */
1622
1623 int32_t operator ==(DoorComboSet a, DoorComboSet b)
1624 {
1625 for(int32_t i=0; i<9; i++)
1626 {
1627 for(int32_t j=0; j<6; j++)
1628 {
1629 if(j<4)
1630 {
1631 if(a.doorcombo_u[i][j]!=b.doorcombo_u[i][j])
1632 {
1633 return false;
1634 }
1635
1636 if(a.doorcset_u[i][j]!=b.doorcset_u[i][j])
1637 {
1638 return false;
1639 }
1640
1641 if(a.doorcombo_d[i][j]!=b.doorcombo_d[i][j])
1642 {
1643 return false;
1644 }
1645
1646 if(a.doorcset_d[i][j]!=b.doorcset_d[i][j])
1647 {
1648 return false;
1649 }
1650 }
1651
1652 if(a.doorcombo_l[i][j]!=b.doorcombo_l[i][j])
1653 {
1654 return false;
1655 }
1656
1657 if(a.doorcset_l[i][j]!=b.doorcset_l[i][j])
1658 {
1659 return false;
1660 }
1661
1662 if(a.doorcombo_r[i][j]!=b.doorcombo_r[i][j])
1663 {
1664 return false;
1665 }
1666
1667 if(a.doorcset_r[i][j]!=b.doorcset_r[i][j])
1668 {
1669 return false;
1670 }
1671 }
1672
1673 if(i<2)
1674 {
1675 if(a.flags[i]!=b.flags[i])
1676 {
1677 return false;
1678 }
1679
1680 if(a.bombdoorcombo_u[i]!=b.bombdoorcombo_u[i])
1681 {
1682 return false;
1683 }
1684
1685 if(a.bombdoorcset_u[i]!=b.bombdoorcset_u[i])
1686 {
1687 return false;
1688 }
1689
1690 if(a.bombdoorcombo_d[i]!=b.bombdoorcombo_d[i])
1691 {
1692 return false;
1693 }
1694
1695 if(a.bombdoorcset_d[i]!=b.bombdoorcset_d[i])
1696 {
1697 return false;
1698 }
1699 }
1700
1701 if(i<3)
1702 {
1703 if(a.bombdoorcombo_l[i]!=b.bombdoorcombo_l[i])
1704 {
1705 return false;
1706 }
1707
1708 if(a.bombdoorcset_l[i]!=b.bombdoorcset_l[i])
1709 {
1710 return false;
1711 }
1712
1713 if(a.bombdoorcombo_r[i]!=b.bombdoorcombo_r[i])
1714 {
1715 return false;
1716 }
1717
1718 if(a.bombdoorcset_r[i]!=b.bombdoorcset_r[i])
1719 {
1720 return false;
1721 }
1722 }
1723
1724 if(a.walkthroughcombo[i]!=b.walkthroughcombo[i])
1725 {
1726 return false;
1727 }
1728
1729 if(a.walkthroughcset[i]!=b.walkthroughcset[i])
1730 {
1731 return false;
1732 }
1733 }
1734
1735 return true;
1736 }
1737
1738 int32_t doortranslations_u[9][4]=
1739 {
1740 {37,38,53,54},
1741 {37,38,39,40},
1742 {37,38,55,56},
1743 {37,38,39,40},
1744 {37,38,53,54},
1745 {37,38,53,54},
1746 {37,38,53,54},
1747 {7,8,23,24},
1748 {7,8,41,42}
1749 };
1750
1751 int32_t doortranslations_d[9][4]=
1752 {
1753 {117,118,133,134},
1754 {135,136,133,134},
1755 {119,120,133,134},
1756 {135,136,133,134},
1757 {117,118,133,134},
1758 {117,118,133,134},
1759 {117,118,133,134},
1760 {151,152,167,168},
1761 {137,138,167,168},
1762 };
1763
1764 //enum {dt_pass=0, dt_lock, dt_shut, dt_boss, dt_olck, dt_osht, dt_obos, dt_wall, dt_bomb, dt_walk, dt_max};
1765 int32_t doortranslations_l[9][6]=
1766 {
1767 {66,67,82,83,98,99},
1768 {66,68,82,84,98,100},
1769 {66,69,82,85,98,101},
1770 {66,68,82,84,98,100},
1771 {66,67,82,83,98,99},
1772 {66,67,82,83,98,99},
1773 {66,67,82,83,98,99},
1774 {64,65,80,81,96,97},
1775 {64,65,80,114,96,97},
1776 };
1777
1778 int32_t doortranslations_r[9][6]=
1779 {
1780
1781 {76,77,92,93,108,109},
1782 {75,77,91,93,107,109},
1783 {74,77,90,93,106,109},
1784 {75,77,91,93,107,109},
1785 {76,77,92,93,108,109},
1786 {76,77,92,93,108,109},
1787 {76,77,92,93,108,109},
1788 {78,79,94,95,110,111},
1789 {78,79,125,95,110,111},
1790 };
1791
1792 int32_t tdcmbdat(int32_t map, int32_t scr, int32_t pos)
1793 {
1794 return (TheMaps[map*MAPSCRS+TEMPLATE].data[pos]&0xFF)+((TheMaps[map*MAPSCRS+scr].old_cpage)<<8);
1795 }
1796
1797 int32_t tdcmbcset(int32_t map, int32_t scr, int32_t pos)
1798 {
1799 //these are here to bypass compiler warnings about unused arguments
1800 map=map;
1801 scr=scr;
1802 pos=pos;
1803
1804 //what does this function do?
1805 // return TheMaps[map*MAPSCRS+TEMPLATE].cset[pos];
1806 return 2;
1807 }
1808
1809 int32_t MakeDoors(int32_t map, int32_t scr)
1810 {
1811 if(!(TheMaps[map*MAPSCRS+scr].valid&mVALID))
1812 {
1813 return 0;
1814 }
1815
1816 DoorComboSet tempdcs;
1817 memset(&tempdcs, 0, sizeof(DoorComboSet));
1818
1819 //up
1820 for(int32_t i=0; i<9; i++)
1821 {
1822 for(int32_t j=0; j<4; j++)
1823 {
1824 tempdcs.doorcombo_u[i][j]=tdcmbdat(map,scr,doortranslations_u[i][j]);
1825 tempdcs.doorcset_u[i][j]=tdcmbcset(map,scr,doortranslations_u[i][j]);
1826 }
1827 }
1828
1829 tempdcs.bombdoorcombo_u[0]=tdcmbdat(map,scr,57);
1830 tempdcs.bombdoorcset_u[0]=tdcmbcset(map,scr,57);
1831 tempdcs.bombdoorcombo_u[1]=tdcmbdat(map,scr,58);
1832 tempdcs.bombdoorcset_u[1]=tdcmbcset(map,scr,58);
1833 tempdcs.walkthroughcombo[0]=tdcmbdat(map,scr,34);
1834 tempdcs.walkthroughcset[0]=tdcmbdat(map,scr,34);
1835
1836 //down
1837 for(int32_t i=0; i<9; i++)
1838 {
1839 for(int32_t j=0; j<4; j++)
1840 {
1841 tempdcs.doorcombo_d[i][j]=tdcmbdat(map,scr,doortranslations_d[i][j]);
1842 tempdcs.doorcset_d[i][j]=tdcmbcset(map,scr,doortranslations_d[i][j]);
1843 }
1844 }
1845
1846 tempdcs.bombdoorcombo_d[0]=tdcmbdat(map,scr,121);
1847
1848 tempdcs.bombdoorcset_d[0]=tdcmbcset(map,scr,121);
1849 tempdcs.bombdoorcombo_d[1]=tdcmbdat(map,scr,122);
1850 tempdcs.bombdoorcset_d[1]=tdcmbcset(map,scr,122);
1851 tempdcs.walkthroughcombo[1]=tdcmbdat(map,scr,34);
1852 tempdcs.walkthroughcset[1]=tdcmbdat(map,scr,34);
1853
1854 //left
1855 // TheMaps[i*MAPSCRS+j].warpdmap=TheOldMap.warpdmap;
1856 for(int32_t i=0; i<9; i++)
1857 {
1858 for(int32_t j=0; j<6; j++)
1859 {
1860 tempdcs.doorcombo_l[i][j]=tdcmbdat(map,scr,doortranslations_l[i][j]);
1861 tempdcs.doorcset_l[i][j]=tdcmbcset(map,scr,doortranslations_l[i][j]);
1862 }
1863 }
1864
1865 for(int32_t j=0; j>6; j++)
1866 {
1867 if((j!=2)&&(j!=3))
1868 {
1869 tempdcs.doorcombo_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_l[dt_bomb][j]];
1870 tempdcs.doorcset_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_l[dt_bomb][j]];
1871 }
1872 }
1873
1874 tempdcs.bombdoorcombo_l[0]=0;
1875 tempdcs.bombdoorcset_l[0]=tdcmbcset(map,scr,115);
1876 tempdcs.bombdoorcombo_l[1]=tdcmbdat(map,scr,115);
1877 tempdcs.bombdoorcset_l[1]=tdcmbcset(map,scr,115);
1878 tempdcs.bombdoorcombo_l[2]=0;
1879 tempdcs.bombdoorcset_l[2]=tdcmbcset(map,scr,115);
1880 tempdcs.walkthroughcombo[2]=tdcmbdat(map,scr,34);
1881 tempdcs.walkthroughcset[2]=tdcmbdat(map,scr,34);
1882
1883 //right
1884 for(int32_t i=0; i<9; i++)
1885 {
1886 for(int32_t j=0; j<6; j++)
1887 {
1888 tempdcs.doorcombo_r[i][j]=tdcmbdat(map,scr,doortranslations_r[i][j]);
1889 tempdcs.doorcset_r[i][j]=tdcmbcset(map,scr,doortranslations_r[i][j]);
1890 }
1891 }
1892
1893 for(int32_t j=0; j>6; j++)
1894 {
1895 if((j!=2)&&(j!=3))
1896 {
1897 tempdcs.doorcombo_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_r[dt_bomb][j]];
1898 tempdcs.doorcset_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_r[dt_bomb][j]];
1899 }
1900 }
1901
1902 tempdcs.bombdoorcombo_r[0]=0;
1903 tempdcs.bombdoorcset_r[0]=tdcmbcset(map,scr,124);
1904 tempdcs.bombdoorcombo_r[1]=tdcmbdat(map,scr,124);
1905 tempdcs.bombdoorcset_r[1]=tdcmbcset(map,scr,124);
1906 tempdcs.bombdoorcombo_r[2]=0;
1907 tempdcs.bombdoorcset_r[2]=tdcmbcset(map,scr,124);
1908 tempdcs.walkthroughcombo[3]=tdcmbdat(map,scr,34);
1909 tempdcs.walkthroughcset[3]=tdcmbdat(map,scr,34);
1910
1911 int32_t k;
1912
1913 for(k=0; k<door_combo_set_count; k++)
1914 {
1915 if(DoorComboSets[k]==tempdcs)
1916 {
1917 break;
1918 }
1919 }
1920
1921 if(k==door_combo_set_count)
1922 {
1923 DoorComboSets[k]=tempdcs;
1924 sprintf(DoorComboSets[k].name, "Door Combo Set %d", k);
1925 ++door_combo_set_count;
1926 }
1927
1928 return k;
1929 /*
1930 doorcombo_u[9][4];
1931 doorcset_u[9][4];
1932 doorcombo_d[9][4];
1933 doorcset_d[9][4];
1934 doorcombo_l[9][6];
1935 doorcset_l[9][6];
1936 doorcombo_r[9][6];
1937 doorcset_r[9][6];
1938 bombdoorcombo_u[2];
1939 bombdoorcset_u[2];
1940 bombdoorcombo_d[2];
1941 bombdoorcset_d[2];
1942 bombdoorcombo_l[3];
1943 bombdoorcset_l[3];
1944 bombdoorcombo_r[3];
1945 bombdoorcset_r[3];
1946 walkthroughcombo[4];
1947 walkthroughcset[4];
1948 */
1949 }
1950
1951 INLINE int32_t tcmbdat2(int32_t map, int32_t scr, int32_t pos)
1952 {
1953 return (TheMaps[map*MAPSCRS+TEMPLATE2].data[pos]&0xFF)+((TheMaps[map*MAPSCRS+scr].old_cpage)<<8);
1954 }
1955
1956 INLINE int32_t tcmbcset2(int32_t map, int32_t pos)
1957 {
1958
1959 return TheMaps[map*MAPSCRS+TEMPLATE2].cset[pos];
1960 }
1961
1962 INLINE int32_t tcmbflag2(int32_t map, int32_t pos)
1963 {
1964 return TheMaps[map*MAPSCRS+TEMPLATE2].sflag[pos];
1965 }
1966
1967
1968 3 void get_questpwd(char *encrypted_pwd, int16_t pwdkey, char *pwd)
1969 {
1970 char temp_pwd[30];
1971 3 memset(temp_pwd,0,30);
1972
1973
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(pwdkey!=0)
1974 {
1975 3 memcpy(temp_pwd,encrypted_pwd,30);
1976 3 temp_pwd[29]=0;
1977
1978
2/2
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 3 times.
93 for(int32_t i=0; i<30; i++)
1979 {
1980 90 temp_pwd[i] -= pwdkey;
1981 90 int32_t t=pwdkey>>15;
1982 90 pwdkey = (pwdkey<<1)+t;
1983 90 }
1984 3 }
1985
1986 3 memcpy(pwd,temp_pwd,30);
1987 3 }
1988
1989
1990 79 bool devpwd()
1991 {
1992 #ifdef _DEBUG
1993 return true;
1994 #endif
1995 79 return !strcmp(zc_get_config("dev","pwd","",App::zquest), (char*)clavio);
1996 }
1997 bool check_questpwd(zquestheader *Header, char *pwd)
1998 {
1999 #if DEVLEVEL > 3
2000 return true;
2001 #endif
2002
2003 if (devpwd()) return true;
2004 if ( (!strcmp(pwd, (char*)clavio)) ) return true;
2005 cvs_MD5Context ctx;
2006 uint8_t md5sum[16];
2007
2008 cvs_MD5Init(&ctx);
2009 cvs_MD5Update(&ctx, (const uint8_t*)pwd, (unsigned)strlen(pwd));
2010 cvs_MD5Final(md5sum, &ctx);
2011
2012 return (memcmp(Header->pwd_hash,md5sum,16)==0);
2013 }
2014
2015 94 void print_quest_metadata(zquestheader const& tempheader, char const* path, byte qst_num)
2016 {
2017 94 zprint2("\n");
2018 94 zprint2("[ZQUEST CREATOR METADATA]\n");
2019
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 if(qst_num < moduledata.max_quest_files)
2020 zprint2("Loading module quest %d\n", qst_num+1);
2021
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
94 if(path) zprint2("Loading '%s'\n", path);
2022
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 if ( tempheader.new_version_id_main > 0 )
2023 {
2024
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
94 if(tempheader.new_version_id_fourth > 0)
2025 zprint2("Last saved in ZQuest Version %d.%d.%d.%d ",
2026 tempheader.new_version_id_main,tempheader.new_version_id_second,
2027 tempheader.new_version_id_third,tempheader.new_version_id_fourth);
2028 94 else zprint2("Last saved in ZQuest Version: %d.%d.%d ",
2029 94 tempheader.new_version_id_main,tempheader.new_version_id_second,
2030 94 tempheader.new_version_id_third);
2031 94 }
2032 else
2033 {
2034 switch ( tempheader.zelda_version )
2035 {
2036 case 0x255:
2037 {
2038 zprint2("Last saved in ZQuest Version: 2.55.0, %s: %d", tempheader.getAlphaStr(), tempheader.getAlphaVer());
2039 break;
2040 }
2041 case 0x254:
2042 {
2043 zprint2("Last saved in ZQuest Version: 2.54.0, Alpha Build ID: %d", tempheader.build);
2044 break;
2045 }
2046 case 0x250:
2047 {
2048 switch(tempheader.build)
2049 {
2050 case 19:
2051 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 1"); break;
2052 case 20:
2053 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 2"); break;
2054 case 21:
2055 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 3"); break;
2056 case 22:
2057 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 4"); break;
2058 case 23:
2059 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 5"); break;
2060 case 24:
2061 zprint2("Last saved in ZQuest Version: 2.50.0, Release"); break;
2062 case 25:
2063 zprint2("Last saved in ZQuest Version: 2.50.1, Gamma 1"); break;
2064 case 26:
2065 zprint2("Last saved in ZQuest Version: 2.50.1, Gamma 2"); break;
2066 case 27:
2067 zprint2("Last saved in ZQuest Version: 2.50.1, Gamma 3"); break;
2068 case 28:
2069 zprint2("Last saved in ZQuest Version: 2.50.1, Release"); break;
2070 case 29:
2071 zprint2("Last saved in ZQuest Version: 2.50.2, Release"); break;
2072 case 30:
2073 zprint2("Last saved in ZQuest Version: 2.50.3, Gamma 1"); break;
2074 case 31:
2075 zprint2("Last saved in ZQuest Version: 2.53.0, Prior to Gamma 3"); break;
2076 case 32:
2077 zprint2("Last saved in ZQuest Version: 2.53.0"); break;
2078 case 33:
2079 zprint2("Last saved in ZQuest Version: 2.53.1"); break;
2080 default:
2081 zprint2("Last saved in ZQuest Version: %x, Build %d", tempheader.zelda_version,tempheader.build); break;
2082
2083 }
2084 break;
2085 }
2086
2087 case 0x211:
2088 {
2089 zprint2("Last saved in ZQuest Version: 2.11, Beta %d", tempheader.build); break;
2090 }
2091 case 0x210:
2092 {
2093 zprint2("Last saved in ZQuest Version: 2.10.x");
2094 if ( tempheader.build ) zprint2("Beta/Build %d\n", tempheader.build);
2095 break;
2096 }
2097 /* These versions cannot be handled here; they will be incorrect at this time. -Z
2098 case 0x193:
2099 {
2100 zprint2("Last saved in ZQuest Version: 1.93, Beta %d\n", tempheader.build); break;
2101 }
2102 case 0x192:
2103 {
2104 zprint2("Last saved in ZQuest Version: 1.92, Beta %d\n", tempheader.build); break;
2105 }
2106 case 0x190:
2107 {
2108 zprint2("Last saved in ZQuest Version: 1.90, Beta/Build %d\n", tempheader.build); break;
2109 }
2110 case 0x184:
2111 {
2112 zprint2("Last saved in ZQuest Version: 1.84, Beta/Build %d\n", tempheader.build); break;
2113 }
2114 case 0x183:
2115 {
2116 zprint2("Last saved in ZQuest Version: 1.83, Beta/Build %d\n", tempheader.build); break;
2117 }
2118 case 0x180:
2119 {
2120 zprint2("Last saved in ZQuest Version: 1.80, Beta/Build %d\n", tempheader.build); break;
2121 }
2122 default:
2123 {
2124 zprint2("Last saved in ZQuest Version: %x, Beta %d\n", tempheader.zelda_version,tempheader.build); break;
2125 }
2126 */
2127 }
2128 }
2129
3/4
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 77 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17 times.
94 if(!tempheader.is_legacy() && tempheader.getAlphaVer())
2130 17 zprint2("%s\n", tempheader.getAlphaVerStr());
2131 77 else zprint2("\n");
2132
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 17 times.
94 if ( tempheader.made_in_module_name[0] ) zprint2("Created with ZC Module: %s\n\n", tempheader.made_in_module_name);
2133
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 17 times.
94 if ( tempheader.new_version_devsig[0] ) zprint2("Developr Signoff by: %s\n", tempheader.new_version_devsig);
2134
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 17 times.
94 if ( tempheader.new_version_compilername[0] ) zprint2("Compiled with: %s, (ID: %d)\n", tempheader.new_version_compilername, tempheader.compilerid);
2135
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 17 times.
94 if ( tempheader.new_version_compilerversion[0] ) zprint2("Compiler Version: %s, (%d,%d,%d,%d)\n", tempheader.new_version_compilerversion,tempheader.compilerversionnumber_first,tempheader.compilerversionnumber_second,tempheader.compilerversionnumber_third,tempheader.compilerversionnumber_fourth);
2136
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
94 if ( tempheader.product_name[0] ) zprint2("Project ID: %s\n", tempheader.product_name);
2137
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 17 times.
94 if ( tempheader.new_version_id_date_day ) zprint2("Editor Built at date and time: %d-%d-%d at @ %s %s\n", tempheader.new_version_id_date_day, tempheader.new_version_id_date_month, tempheader.new_version_id_date_year, tempheader.build_timestamp, tempheader.build_timezone);
2138 94 zprint2("\n");
2139 94 }
2140
2141 128 int32_t readheader(PACKFILE *f, zquestheader *Header, bool keepdata, byte printmetadata)
2142 {
2143 int32_t dummy;
2144 zquestheader tempheader;
2145 char dummybuf[80];
2146 byte temp_map_count;
2147 byte temp_midi_flags[MIDIFLAGS_SIZE];
2148 word version;
2149 char temp_pwd[30], temp_pwd2[30];
2150 int16_t temp_pwdkey;
2151 cvs_MD5Context ctx;
2152 128 memset(temp_midi_flags, 0, MIDIFLAGS_SIZE);
2153 128 memset(&tempheader, 0, sizeof(tempheader));
2154 128 memset(FFCore.quest_format, 0, sizeof(FFCore.quest_format));
2155
2156
2157
2158
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(!pfread(tempheader.id_str,sizeof(tempheader.id_str),f,true)) // first read old header
2159 {
2160 Z_message("Unable to read header string\n");
2161 return qe_invalid;
2162 }
2163
2164 // check header
2165
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2166 {
2167 if(strcmp(tempheader.id_str,QH_IDSTR))
2168 {
2169 Z_message("Invalid header string: '%s' (was expecting '%s' or '%s')\n", tempheader.id_str, QH_IDSTR, QH_NEWIDSTR);
2170 return qe_invalid;
2171 }
2172 }
2173
2174 128 int32_t templatepath_len=0;
2175
2176 128 tempheader.external_zinfo = false;
2177 128 read_zinfo = false;
2178
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!strcmp(tempheader.id_str,QH_IDSTR)) //pre-1.93 version
2179 {
2180 byte padding;
2181
2182 if(!p_getc(&padding,f,true))
2183 {
2184 return qe_invalid;
2185 }
2186
2187 if(!p_igetw(&tempheader.zelda_version,f,true))
2188 {
2189 return qe_invalid;
2190 }
2191
2192 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2193
2194 if(tempheader.zelda_version > ZELDA_VERSION)
2195 {
2196 return qe_version;
2197 }
2198
2199 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2200
2201 if(strcmp(tempheader.id_str,QH_IDSTR))
2202 {
2203 return qe_invalid;
2204 }
2205
2206 if(bad_version(tempheader.zelda_version))
2207 {
2208 return qe_obsolete;
2209 }
2210
2211 if(!p_igetw(&tempheader.internal,f,true))
2212 {
2213 return qe_invalid;
2214 }
2215
2216 if(!p_getc(&tempheader.quest_number,f,true))
2217 {
2218 return qe_invalid;
2219 }
2220
2221 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2222
2223 if(!pfread(&quest_rules[0],2,f,true))
2224 {
2225 return qe_invalid;
2226 }
2227
2228 if(!p_getc(&temp_map_count,f,true))
2229 {
2230 return qe_invalid;
2231 }
2232
2233 FFCore.quest_format[qMapCount] = temp_map_count;
2234
2235 if(!p_getc(&tempheader.old_str_count,f,true))
2236 {
2237 return qe_invalid;
2238 }
2239
2240 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f,true))
2241 {
2242 return qe_invalid;
2243 }
2244
2245 if(!pfread(temp_midi_flags,4,f,true))
2246 {
2247 return qe_invalid;
2248 }
2249
2250 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f,true))
2251 {
2252 return qe_invalid;
2253 }
2254
2255 if(!pfread(dummybuf,14,f,true))
2256 {
2257 return qe_invalid;
2258 }
2259
2260 if(!pfread(&quest_rules[2],2,f,true))
2261 {
2262 return qe_invalid;
2263 }
2264
2265 if(!p_getc(&dummybuf,f,true))
2266 {
2267 return qe_invalid;
2268 }
2269
2270 if(!pfread(tempheader.version,9,f,true))
2271 {
2272 return qe_invalid;
2273 }
2274
2275 if(!pfread(tempheader.title,sizeof(tempheader.title),f,true))
2276 {
2277 return qe_invalid;
2278 }
2279 // These fields are expected to end in null bytes!
2280 tempheader.title[sizeof(tempheader.title)-1] = 0;
2281
2282 if(!pfread(tempheader.author,sizeof(tempheader.author),f,true))
2283 {
2284 return qe_invalid;
2285 }
2286 tempheader.author[sizeof(tempheader.author)-1] = 0;
2287
2288 if(!p_getc(&padding,f,true))
2289 {
2290 return qe_invalid;
2291 }
2292
2293 if(!p_igetw(&temp_pwdkey,f,true))
2294 {
2295 return qe_invalid;
2296 }
2297
2298 if(!pfread(temp_pwd,30,f,true))
2299 {
2300 return qe_invalid;
2301 }
2302
2303 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2304 cvs_MD5Init(&ctx);
2305 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strlen(temp_pwd2));
2306 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2307
2308 if(tempheader.zelda_version < 0x177) // lacks new header stuff...
2309 {
2310 //memset(tempheader.minver,0,20); // char minver[9], byte build, byte foo[10]
2311 // Not anymore...
2312 memset(tempheader.minver,0,17);
2313 tempheader.build=0;
2314 tempheader.use_keyfile=0;
2315 memset(tempheader.old_foo, 0, 9);
2316 }
2317 else
2318 {
2319 if(!pfread(tempheader.minver,9,f,true))
2320 {
2321 return qe_invalid;
2322 }
2323
2324 if(!p_getc(&tempheader.build,f,true))
2325 {
2326 return qe_invalid;
2327 }
2328
2329 FFCore.quest_format[vBuild] = tempheader.build;
2330
2331 if(!p_getc(&tempheader.use_keyfile,f,true))
2332 {
2333 return qe_invalid;
2334 }
2335
2336 if(!pfread(dummybuf,9,f,true))
2337 {
2338 return qe_invalid;
2339 }
2340 } // starting at minver
2341
2342 if(tempheader.zelda_version < 0x187) // lacks newer header stuff...
2343 {
2344 memset(&quest_rules[4],0,16); // word rules3..rules10
2345 }
2346 else
2347 {
2348 if(!pfread(&quest_rules[4],16,f,true)) // read new header additions
2349 {
2350 return qe_invalid; // starting at rules3
2351 }
2352
2353 if(tempheader.zelda_version <= 0x190)
2354 {
2355 set_bit(quest_rules,qr_MEANPLACEDTRAPS,0);
2356 }
2357 }
2358
2359 if((tempheader.zelda_version < 0x192)||
2360 ((tempheader.zelda_version == 0x192)&&(tempheader.build<149)))
2361 {
2362 set_bit(quest_rules,qr_BRKNSHLDTILES,(get_bit(quest_rules,qr_BRKBLSHLDS_DEP)));
2363 set_bit(deprecated_rules,qr_BRKBLSHLDS_DEP,1);
2364 }
2365
2366 if(tempheader.zelda_version >= 0x192) // lacks newer header stuff...
2367 {
2368 byte *mf=temp_midi_flags;
2369
2370 if((tempheader.zelda_version == 0x192)&&(tempheader.build<178))
2371 {
2372 mf=(byte*)dummybuf;
2373 }
2374
2375 if(!pfread(mf,32,f,true)) // read new header additions
2376 {
2377 return qe_invalid; // starting at foo2
2378 }
2379
2380 if(!pfread(dummybuf,18,f,true)) // read new header additions
2381 {
2382 return qe_invalid; // starting at foo2
2383 }
2384 }
2385
2386 if((tempheader.zelda_version < 0x192)||
2387 ((tempheader.zelda_version == 0x192)&&(tempheader.build<145)))
2388 {
2389 memset(tempheader.templatepath,0,2048);
2390 }
2391 else
2392 {
2393 if(!pfread(tempheader.templatepath,280,f,true)) // read templatepath
2394 {
2395 return qe_invalid;
2396 }
2397 }
2398
2399 if((tempheader.zelda_version < 0x192)||
2400 ((tempheader.zelda_version == 0x192)&&(tempheader.build<186)))
2401 {
2402 tempheader.use_keyfile=0;
2403 }
2404 }
2405 else
2406 {
2407 //section id
2408
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(!p_mgetl(&dummy,f,true))
2409 {
2410 return qe_invalid;
2411 }
2412
2413 //section version info
2414
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!p_igetw(&version,f,true))
2415 {
2416 return qe_invalid;
2417 }
2418
2419 128 FFCore.quest_format[vHeader] = version;
2420
2421
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!p_igetw(&dummy,f,true))
2422 {
2423 return qe_invalid;
2424 }
2425
2426 //section size
2427
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!p_igetl(&dummy,f,true))
2428 {
2429 return qe_invalid;
2430 }
2431
2432 //finally... section data
2433
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!p_igetw(&tempheader.zelda_version,f,true))
2434 {
2435 return qe_invalid;
2436 }
2437
2438 128 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2439
2440 //do some quick checking...
2441
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(tempheader.zelda_version > ZELDA_VERSION)
2442 {
2443 return qe_version;
2444 }
2445
2446
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2447 {
2448 return qe_invalid;
2449 }
2450
2451
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(bad_version(tempheader.zelda_version))
2452 {
2453 return qe_obsolete;
2454 }
2455
2456
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!p_getc(&tempheader.build,f,true))
2457 {
2458 return qe_invalid;
2459 }
2460
2461 128 FFCore.quest_format[vBuild] = tempheader.build;
2462
2463
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 125 times.
128 if(version<3)
2464 {
2465
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!pfread(temp_pwd,30,f,true))
2466 {
2467 return qe_invalid;
2468 }
2469
2470
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_igetw(&temp_pwdkey,f,true))
2471 {
2472 return qe_invalid;
2473 }
2474
2475 3 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2476 3 cvs_MD5Init(&ctx);
2477 3 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strlen(temp_pwd2));
2478 3 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2479 3 }
2480 else
2481 {
2482
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!pfread(tempheader.pwd_hash,sizeof(tempheader.pwd_hash),f,true))
2483 {
2484 return qe_invalid;
2485 }
2486 }
2487
2488
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!p_igetw(&tempheader.internal,f,true))
2489 {
2490 return qe_invalid;
2491 }
2492
2493
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!p_getc(&tempheader.quest_number,f,true))
2494 {
2495 return qe_invalid;
2496 }
2497
2498 128 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2499
2500 128 size_t versz = version < 8 ? 9 : 16;
2501
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!pfread(tempheader.version,versz,f,true))
2502 {
2503 return qe_invalid;
2504 }
2505
2506 //FFCore.quest_format[qQuestVersion] = tempheader.version;
2507 //needs to be copied as char[9] or stored as a s.str
2508
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!pfread(tempheader.minver,versz,f,true))
2509 {
2510 return qe_invalid;
2511 }
2512
2513 //FFCore.quest_format[qMinQuestVersion] = tempheader.minver;
2514
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!pfread(tempheader.title,sizeof(tempheader.title),f,true))
2515 {
2516 return qe_invalid;
2517 }
2518 128 tempheader.title[sizeof(tempheader.title)-1] = 0;
2519
2520
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!pfread(tempheader.author,sizeof(tempheader.author),f,true))
2521 {
2522 return qe_invalid;
2523 }
2524 128 tempheader.author[sizeof(tempheader.author)-1] = 0;
2525
2526
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!p_getc(&tempheader.use_keyfile,f,true))
2527 {
2528 return qe_invalid;
2529 }
2530
2531 /*
2532 if(!pfread(tempheader.data_flags,sizeof(tempheader.data_flags),f,true))
2533 {
2534 return qe_invalid;
2535 }
2536 */
2537
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f,true))
2538 {
2539 return qe_invalid;
2540 }
2541
2542
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!pfread(&dummybuf,4,f,true))
2543 {
2544 return qe_invalid;
2545 }
2546
2547
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f,true))
2548 {
2549 return qe_invalid;
2550 }
2551
2552
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!pfread(dummybuf,14,f,true))
2553 {
2554 return qe_invalid;
2555 }
2556
2557 128 templatepath_len=sizeof(tempheader.templatepath);
2558
2559
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 3 times.
128 if(version==1)
2560 {
2561 3 templatepath_len=280;
2562 3 }
2563
2564
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!pfread(tempheader.templatepath,templatepath_len,f,true))
2565 {
2566 return qe_invalid;
2567 }
2568
2569
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!p_getc(&temp_map_count,f,true))
2570 {
2571 return qe_invalid;
2572 }
2573
2574
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 77 times.
128 if(version>=4)
2575 {
2576
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!p_igetl(&tempheader.new_version_id_main,f,true))
2577 {
2578 return qe_invalid;
2579 }
2580
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!p_igetl(&tempheader.new_version_id_second,f,true))
2581 {
2582 return qe_invalid;
2583 }
2584
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!p_igetl(&tempheader.new_version_id_third,f,true))
2585 {
2586 return qe_invalid;
2587 }
2588
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!p_igetl(&tempheader.new_version_id_fourth,f,true))
2589 {
2590 return qe_invalid;
2591 }
2592
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!p_igetl(&tempheader.new_version_id_alpha,f,true))
2593 {
2594 return qe_invalid;
2595 }
2596
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!p_igetl(&tempheader.new_version_id_beta,f,true))
2597 {
2598 return qe_invalid;
2599 }
2600
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!p_igetl(&tempheader.new_version_id_gamma,f,true))
2601 {
2602 return qe_invalid;
2603 }
2604
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!p_igetl(&tempheader.new_version_id_release,f,true))
2605 {
2606 return qe_invalid;
2607 }
2608
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!p_igetw(&tempheader.new_version_id_date_year,f,true))
2609 {
2610 return qe_invalid;
2611 }
2612
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!p_getc(&tempheader.new_version_id_date_month,f,true))
2613 {
2614 return qe_invalid;
2615 }
2616
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!p_getc(&tempheader.new_version_id_date_day,f,true))
2617 {
2618 return qe_invalid;
2619 }
2620
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!p_getc(&tempheader.new_version_id_date_hour,f,true))
2621 {
2622 return qe_invalid;
2623 }
2624
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!p_getc(&tempheader.new_version_id_date_minute,f,true))
2625 {
2626 return qe_invalid;
2627 }
2628
2629
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!pfread(tempheader.new_version_devsig,256,f,true))
2630 {
2631 return qe_invalid;
2632 }
2633
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
51 if(!strcmp(tempheader.new_version_devsig, "Venrob"))
2634 strcpy(tempheader.new_version_devsig, "EmilyV99");
2635
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!pfread(tempheader.new_version_compilername,256,f,true))
2636 {
2637 return qe_invalid;
2638 }
2639
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!pfread(tempheader.new_version_compilerversion,256,f,true))
2640 {
2641 return qe_invalid;
2642 }
2643
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!pfread(tempheader.product_name,1024,f,true))
2644 {
2645 return qe_invalid;
2646 }
2647
2648
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!p_getc(&tempheader.compilerid,f,true))
2649 {
2650 return qe_invalid;
2651 }
2652
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!p_igetl(&tempheader.compilerversionnumber_first,f,true))
2653 {
2654 return qe_invalid;
2655 }
2656
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!p_igetl(&tempheader.compilerversionnumber_second,f,true))
2657 {
2658 return qe_invalid;
2659 }
2660
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!p_igetl(&tempheader.compilerversionnumber_third,f,true))
2661 {
2662 return qe_invalid;
2663 }
2664
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!p_igetl(&tempheader.compilerversionnumber_fourth,f,true))
2665 {
2666 return qe_invalid;
2667 }
2668
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!p_igetw(&tempheader.developerid,f,true))
2669 {
2670 return qe_invalid;
2671 }
2672
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!pfread(tempheader.made_in_module_name,1024,f,true))
2673 {
2674 return qe_invalid;
2675 }
2676
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!pfread(tempheader.build_datestamp,256,f,true))
2677 {
2678 return qe_invalid;
2679 }
2680
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
51 if(!pfread(tempheader.build_timestamp,256,f,true))
2681 {
2682 return qe_invalid;
2683 }
2684 51 }
2685 else // <4
2686 {
2687 77 tempheader.new_version_id_main = 0;
2688 77 tempheader.new_version_id_second = 0;
2689 77 tempheader.new_version_id_third = 0;
2690 77 tempheader.new_version_id_fourth = 0;
2691 77 tempheader.new_version_id_alpha = 0;
2692 77 tempheader.new_version_id_beta = 0;
2693 77 tempheader.new_version_id_gamma = 0;
2694 77 tempheader.new_version_id_release = 0;
2695 77 tempheader.new_version_id_date_year = 0;
2696 77 tempheader.new_version_id_date_month = 0;
2697 77 tempheader.new_version_id_date_day = 0;
2698 77 tempheader.new_version_id_date_hour = 0;
2699 77 tempheader.new_version_id_date_minute = 0;
2700
2701 77 memset(tempheader.new_version_devsig, 0, 256);
2702 77 memset(tempheader.new_version_compilername, 0, 256);
2703 77 memset(tempheader.new_version_compilerversion, 0, 256);
2704 77 memset(tempheader.product_name, 0, 1024);
2705 77 strcpy(tempheader.product_name, "ZQuest Creator Suite");
2706
2707 77 tempheader.compilerid = 0;
2708 77 tempheader.compilerversionnumber_first = 0;
2709 77 tempheader.compilerversionnumber_second = 0;
2710 77 tempheader.compilerversionnumber_third = 0;
2711 77 tempheader.compilerversionnumber_fourth = 0;
2712 77 tempheader.developerid = 0;
2713
2714 77 memset(tempheader.made_in_module_name, 0, 1024);
2715 77 memset(tempheader.build_datestamp, 0, 256);
2716 77 memset(tempheader.build_timestamp, 0, 256);
2717 }
2718
2719
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 77 times.
128 if ( version >= 5 )
2720 {
2721
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!pfread(tempheader.build_timezone,6,f,true))
2722 {
2723 return qe_invalid;
2724 }
2725 51 }
2726 else // < 5
2727 {
2728 77 memset(tempheader.build_timezone, 0, 6);
2729 }
2730
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 51 times.
128 if ( version >= 6 )
2731 {
2732 byte b;
2733
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!p_getc(&b,f,true))
2734 {
2735 return qe_invalid;
2736 }
2737 51 tempheader.external_zinfo = b?true:false;
2738 51 read_zinfo = true;
2739 51 }
2740
2741
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 77 times.
128 if(version >= 7)
2742 {
2743
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!p_getc(&(tempheader.new_version_is_nightly),f,true))
2744 {
2745 return qe_invalid;
2746 }
2747 51 }
2748 else
2749 {
2750 77 tempheader.new_version_is_nightly = false;
2751
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(tempheader.zelda_version < 0x255)
2752 {
2753
2/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 74 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
77 switch(tempheader.zelda_version)
2754 {
2755 case 0x254:
2756 tempheader.new_version_id_main = 2;
2757 tempheader.new_version_id_second = 54;
2758 break;
2759 case 0x250:
2760
5/16
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 22 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 5 times.
✓ Branch 11 taken 24 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 15 times.
✓ Branch 14 taken 8 times.
✗ Branch 15 not taken.
74 switch(tempheader.build)
2761 {
2762 case 19:
2763 tempheader.new_version_id_main = 2;
2764 tempheader.new_version_id_second = 50;
2765 tempheader.new_version_id_gamma = 1;
2766 break;
2767 case 20:
2768 tempheader.new_version_id_main = 2;
2769 tempheader.new_version_id_second = 50;
2770 tempheader.new_version_id_gamma = 2;
2771 break;
2772 case 21:
2773 tempheader.new_version_id_main = 2;
2774 tempheader.new_version_id_second = 50;
2775 tempheader.new_version_id_gamma = 3;
2776 break;
2777 case 22:
2778 tempheader.new_version_id_main = 2;
2779 tempheader.new_version_id_second = 50;
2780 tempheader.new_version_id_gamma = 4;
2781 break;
2782 case 23:
2783 tempheader.new_version_id_main = 2;
2784 tempheader.new_version_id_second = 50;
2785 tempheader.new_version_id_gamma = 5;
2786 break;
2787 case 24:
2788 22 tempheader.new_version_id_main = 2;
2789 22 tempheader.new_version_id_second = 50;
2790 22 tempheader.new_version_id_release = -1;
2791 22 break;
2792 case 25:
2793 tempheader.new_version_id_main = 2;
2794 tempheader.new_version_id_second = 50;
2795 tempheader.new_version_id_third = 1;
2796 tempheader.new_version_id_gamma = 1;
2797 break;
2798 case 26:
2799 tempheader.new_version_id_main = 2;
2800 tempheader.new_version_id_second = 50;
2801 tempheader.new_version_id_third = 1;
2802 tempheader.new_version_id_gamma = 2;
2803 break;
2804 case 27:
2805 tempheader.new_version_id_main = 2;
2806 tempheader.new_version_id_second = 50;
2807 tempheader.new_version_id_third = 1;
2808 tempheader.new_version_id_gamma = 3;
2809 break;
2810 case 28:
2811 5 tempheader.new_version_id_main = 2;
2812 5 tempheader.new_version_id_second = 50;
2813 5 tempheader.new_version_id_third = 1;
2814 5 tempheader.new_version_id_release = -1;
2815 5 break;
2816 case 29:
2817 24 tempheader.new_version_id_main = 2;
2818 24 tempheader.new_version_id_second = 50;
2819 24 tempheader.new_version_id_third = 2;
2820 24 tempheader.new_version_id_release = -1;
2821 24 break;
2822 case 30:
2823 tempheader.new_version_id_main = 2;
2824 tempheader.new_version_id_second = 50;
2825 tempheader.new_version_id_third = 3;
2826 tempheader.new_version_id_gamma = 1;
2827 break;
2828 case 31:
2829 15 tempheader.new_version_id_main = 2;
2830 15 tempheader.new_version_id_second = 53;
2831 15 tempheader.new_version_id_gamma = -1;
2832 15 break;
2833 case 32:
2834 8 tempheader.new_version_id_main = 2;
2835 8 tempheader.new_version_id_second = 53;
2836 8 tempheader.new_version_id_release = -1;
2837 8 break;
2838 case 33:
2839 tempheader.new_version_id_main = 2;
2840 tempheader.new_version_id_second = 53;
2841 tempheader.new_version_id_third = 1;
2842 break;
2843 }
2844 74 break;
2845
2846 case 0x211:
2847 tempheader.new_version_id_main = 2;
2848 tempheader.new_version_id_second = 11;
2849 tempheader.new_version_id_beta = tempheader.build;
2850 break;
2851 case 0x210:
2852 3 tempheader.new_version_id_main = 2;
2853 3 tempheader.new_version_id_second = 10;
2854 3 tempheader.new_version_id_beta = tempheader.build;
2855 3 break;
2856 }
2857 77 }
2858 }
2859
2/4
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 128 times.
128 if(printmetadata || __isZQuest)
2860 {
2861 print_quest_metadata(tempheader, loading_qst_name, loading_qst_num);
2862 }
2863 }
2864
2865 //{ Version Warning
2866 128 int32_t vercmp = tempheader.compareVer();
2867 128 int32_t astatecmp = compare(int32_t(tempheader.getAlphaState()), ALPHA_STATE);
2868 128 int32_t avercmp = compare(tempheader.getAlphaVer(), ALPHA_VER);
2869
4/6
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 51 times.
✓ Branch 3 taken 77 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 51 times.
179 if(vercmp > 0 || (!vercmp &&
2870
2/4
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 51 times.
✗ Branch 3 not taken.
51 (astatecmp > 0 || (!astatecmp &&
2871 51 avercmp > 0))))
2872 {
2873 bool r = true;
2874 if(loadquest_report)
2875 {
2876 enter_sys_pal();
2877 AlertDialog("Quest saved in newer version",
2878 "This quest was last saved in a newer version of ZQuest."
2879 " Attempting to load this quest may not work correctly; to"
2880 " avoid issues, try loading this quest in at least '" + std::string(tempheader.getVerStr()) + "'"
2881 "\n\nWould you like to continue loading anyway? (Not recommended)",
2882 [&](bool ret,bool)
2883 {
2884 r = ret;
2885 }).show();
2886 exit_sys_pal();
2887 }
2888 if(!r)
2889 return qe_silenterr;
2890 }
2891
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 else if(tempheader.compareDate() > 0)
2892 {
2893 bool r = true;
2894 if(loadquest_report)
2895 {
2896 enter_sys_pal();
2897 AlertDialog("Quest saved in newer build",
2898 fmt::format("This quest was last saved in a newer build of ZQuest, and may have"
2899 " issues loading in this build."
2900 "\n{}"
2901 "\n\nWould you like to continue loading anyway?",
2902 tempheader.getVerCmpStr()),
2903 [&](bool ret,bool)
2904 {
2905 r = ret;
2906 }).show();
2907 exit_sys_pal();
2908 }
2909 if(!r)
2910 return qe_silenterr;
2911 }
2912 //}
2913
2914 128 read_ext_zinfo = tempheader.external_zinfo;
2915
2916
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(keepdata==true)
2917 {
2918 128 memcpy(Header, &tempheader, sizeof(tempheader));
2919 128 map_count=temp_map_count;
2920 128 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
2921 128 }
2922
2923 128 return 0;
2924 128 }
2925
2926 99 int32_t readrules(PACKFILE *f, zquestheader *Header, bool keepdata)
2927 {
2928 int32_t dummy;
2929 zquestheader tempheader;
2930 99 word s_version=0;
2931 99 dword compatrule_version=0;
2932
2933 99 memcpy(&tempheader, Header, sizeof(tempheader));
2934
2935
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(tempheader.zelda_version >= 0x193)
2936 {
2937 //section version info
2938
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&s_version,f,true))
2939 {
2940 return qe_invalid;
2941 }
2942
2943 99 FFCore.quest_format[vRules] = s_version;
2944
2945
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&dummy,f,true))
2946 {
2947 return qe_invalid;
2948 }
2949
2950
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 22 times.
99 if(s_version > 16)
2951 {
2952
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(!p_igetl(&compatrule_version,f,true))
2953 {
2954 return qe_invalid;
2955 }
2956 22 }
2957 99 FFCore.quest_format[vCompatRule] = compatrule_version;
2958
2959 //section size
2960
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetl(&dummy,f,true))
2961 {
2962 return qe_invalid;
2963 }
2964
2965
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 22 times.
99 if ( s_version < 15 )
2966 {
2967 //finally... section data
2968
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(!pfread(quest_rules,QUESTRULES_SIZE,f,true))
2969 {
2970 return qe_invalid;
2971 }
2972 77 }
2973 else
2974 {
2975
2976
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if(!pfread(quest_rules,QUESTRULES_NEW_SIZE,f,true))
2977 {
2978 return qe_invalid;
2979 }
2980
2981 }
2982 99 }
2983
2984 //al_trace("Rules version %d\n", s_version);
2985 //{ bunch of compat stuff
2986 99 memcpy(deprecated_rules, quest_rules, QUESTRULES_NEW_SIZE);
2987
2988
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version<2)
2989 {
2990 3 set_bit(quest_rules,14,0);
2991 3 set_bit(quest_rules,27,0);
2992 3 set_bit(quest_rules,28,0);
2993 3 set_bit(quest_rules,29,0);
2994 3 set_bit(quest_rules,30,0);
2995 3 set_bit(quest_rules,32,0);
2996 3 set_bit(quest_rules,36,0);
2997 3 set_bit(quest_rules,49,0);
2998 3 set_bit(quest_rules,50,0);
2999 3 set_bit(quest_rules,51,0);
3000 3 set_bit(quest_rules,68,0);
3001 3 set_bit(quest_rules,75,0);
3002 3 set_bit(quest_rules,76,0);
3003 3 set_bit(quest_rules,98,0);
3004 3 set_bit(quest_rules,110,0);
3005 3 set_bit(quest_rules,113,0);
3006 3 set_bit(quest_rules,116,0);
3007 3 set_bit(quest_rules,102,0);
3008 3 set_bit(quest_rules,132,0);
3009 3 }
3010
3011 //Now, do any updates...
3012
3/6
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 96 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if((tempheader.zelda_version < 0x211)||((tempheader.zelda_version == 0x211)&&(tempheader.build<18)))
3013 {
3014 3 set_bit(quest_rules, qr_SMOOTHVERTICALSCROLLING,1);
3015 3 set_bit(quest_rules, qr_REPLACEOPENDOORS, 1);
3016 3 set_bit(quest_rules, qr_OLDLENSORDER, 1);
3017 3 set_bit(quest_rules, qr_NOFAIRYGUYFIRES, 1);
3018 3 set_bit(quest_rules, qr_TRIGGERSREPEAT, 1);
3019 3 }
3020
3021
2/6
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
3022 {
3023 set_bit(quest_rules,qr_WALLFLIERS,1);
3024 }
3025
3026
2/6
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<4)))
3027 {
3028 set_bit(quest_rules,qr_NOBOMBPALFLASH,1);
3029 }
3030
3031
2/6
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
3032 {
3033 set_bit(quest_rules,qr_NOSCROLLCONTINUE,1);
3034 }
3035
3036
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(tempheader.zelda_version <= 0x210)
3037 {
3038 3 set_bit(quest_rules,qr_ARROWCLIP,1);
3039 3 }
3040
3041
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(tempheader.zelda_version == 0x210)
3042 {
3043 3 set_bit(quest_rules, qr_NOSCROLLCONTINUE, get_bit(quest_rules, qr_CMBCYCLELAYERS));
3044 3 set_bit(quest_rules, qr_CMBCYCLELAYERS, 0);
3045 3 set_bit(quest_rules, qr_CONT_SWORD_TRIGGERS, 1);
3046 3 }
3047
3048
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(tempheader.zelda_version <= 0x210)
3049 {
3050 3 set_bit(quest_rules,qr_OLDSTYLEWARP,1);
3051 3 set_bit(quest_rules,qr_210_WARPRETURN,1);
3052 3 }
3053
3054 //might not be correct
3055
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(tempheader.zelda_version < 0x210)
3056 {
3057 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP,1);
3058 set_bit(quest_rules, qr_OLDHOOKSHOTGRAB,1);
3059 }
3060
3061
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(tempheader.zelda_version < 0x211)
3062 {
3063 3 set_bit(quest_rules, qr_WRONG_BRANG_TRAIL_DIR,1);
3064 3 }
3065
3066
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
99 if(tempheader.zelda_version == 0x192 && tempheader.build == 163)
3067 {
3068 set_bit(quest_rules, qr_192b163_WARP,1);
3069 }
3070
3071
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(tempheader.zelda_version == 0x210)
3072 {
3073 3 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP, get_bit(quest_rules, qr_DMGCOMBOPRI));
3074 3 set_bit(quest_rules, qr_DMGCOMBOPRI, 0);
3075 3 }
3076
3077
3/6
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 96 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build<15))
3078 {
3079 3 set_bit(quest_rules, qr_OLDPICKUP,1);
3080 3 }
3081
3082
3/6
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 96 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build < 18))
3083 {
3084 3 set_bit(quest_rules,qr_NOSOLIDDAMAGECOMBOS, 1);
3085 3 set_bit(quest_rules, qr_ITEMPICKUPSETSBELOW, 1); // broke around build 400
3086 3 }
3087
3088
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(tempheader.zelda_version < 0x250) // version<0x250 checks for beta 18; build was set to 18 prematurely
3089 {
3090 3 set_bit(quest_rules,qr_HOOKSHOTDOWNBUG, 1);
3091 3 }
3092
3093
4/4
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 25 times.
✓ Branch 2 taken 52 times.
✓ Branch 3 taken 22 times.
99 if(tempheader.zelda_version == 0x250 && tempheader.build == 24) // Annoying...
3094 {
3095 22 set_bit(quest_rules,qr_PEAHATCLOCKVULN, 1);
3096 22 }
3097
3098
5/6
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 74 times.
✓ Branch 3 taken 22 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 74 times.
99 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 22)) //22 is 2.50.0 RC4. Gotta set the door repair QR... -Dimi
3099 {
3100 3 set_bit(quest_rules,qr_OLD_DOORREPAIR, 1);
3101 3 }
3102
3103
5/6
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 74 times.
✓ Branch 3 taken 22 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 74 times.
99 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 20)) //20 is 2.50.0 RC1 and RC2 (cause it didn't get bumped). Okay I'm gonna be honest I have no idea if any 2.50 build was available before RC1, but gonna try and cover my ass here -Dimi
3104 {
3105 3 set_bit(quest_rules,qr_OLD_SECRETMONEY, 1);
3106 3 }
3107
3108
6/6
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 74 times.
✓ Branch 3 taken 22 times.
✓ Branch 4 taken 22 times.
✓ Branch 5 taken 52 times.
99 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 28)) //28 is 2.50.1 final. Potion bug might have been used, I dunno. -Dimi
3109 {
3110 25 set_bit(quest_rules,qr_OLD_POTION_OR_HC, 1);
3111 25 }
3112
3113
6/6
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 74 times.
✓ Branch 3 taken 22 times.
✓ Branch 4 taken 22 times.
✓ Branch 5 taken 52 times.
99 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<28))
3114 {
3115 25 set_bit(quest_rules, qr_OFFSCREENWEAPONS, 1);
3116 25 }
3117
3118 //Bombchu fix.
3119
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 74 times.
99 if(tempheader.zelda_version == 0x250)
3120 {
3121
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 22 times.
74 if ( tempheader.build == 24 ) //2.50.0
3122 {
3123 22 set_bit(quest_rules, qr_BOMBCHUSUPERBOMB, 1);
3124 22 }
3125
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 5 times.
74 if ( tempheader.build == 28 ) //2.50.1
3126 {
3127 5 set_bit(quest_rules, qr_BOMBCHUSUPERBOMB, 1);
3128 5 }
3129
2/2
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 24 times.
74 if ( tempheader.build == 29 ) //2.50.2
3130 {
3131 24 set_bit(quest_rules, qr_BOMBCHUSUPERBOMB, 0);
3132 24 }
3133
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 if ( tempheader.build == 30 ) //2.50.3RC1
3134 {
3135 set_bit(quest_rules, qr_BOMBCHUSUPERBOMB, 0);
3136 }
3137 74 }
3138
3139
6/6
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 74 times.
✓ Branch 3 taken 22 times.
✓ Branch 4 taken 27 times.
✓ Branch 5 taken 47 times.
99 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
3140 {
3141 // qr_OFFSETEWPNCOLLISIONFIX
3142 // All 'official' quests need this disabled.
3143 // All 2.10 and lower quests need this enabled to preseve compatability.
3144 // All 2.11 - 2.5.1 quests should have it set also, due to a bug in about half of all the betas.
3145
3146 //~Gleeok
3147 30 set_bit(quest_rules, qr_OFFSETEWPNCOLLISIONFIX, 1); //This has to be set!!!!
3148
3149 // Broke in build 695
3150
3/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 27 times.
30 if(tempheader.zelda_version>=0x211 && tempheader.build>=18)
3151 27 set_bit(quest_rules, qr_BROKENSTATUES, 1);
3152 30 }
3153
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if (tempheader.zelda_version <= 0x190)
3154 {
3155 set_bit(quest_rules, qr_COPIED_SWIM_SPRITES, 1);
3156 }
3157
7/10
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 25 times.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 22 times.
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 22 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 22 times.
99 if ( (tempheader.zelda_version == 0x250 && tempheader.build < 33) || tempheader.zelda_version == 0x254 || tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3158 {
3159 77 set_bit(quest_rules, qr_OLD_SLASHNEXT_SECRETS, 1);
3160 77 }
3161
3162
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if ( (tempheader.zelda_version < 0x211) ) //2.10 water and ladder interaction
3163 {
3164 3 set_bit(quest_rules, qr_OLD_210_WATER, 1);
3165 3 }
3166
3167
4/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
99 if ( (tempheader.zelda_version < 0x255 ) || (tempheader.zelda_version == 0x255 && tempheader.build < 51 ) ) //2.10 water and ladder interaction
3168 {
3169 77 set_bit(quest_rules,qr_STEP_IS_FLOAT,0);
3170 77 }
3171
3172
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if ( tempheader.zelda_version < 0x250 )
3173 {
3174 3 set_bit(quest_rules, qr_8WAY_SHOT_SFX, 1);
3175 3 }
3176
3177
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version < 3)
3178 {
3179 3 set_bit(quest_rules, qr_HOLDNOSTOPMUSIC, 1);
3180 3 set_bit(quest_rules, qr_CAVEEXITNOSTOPMUSIC, 1);
3181 3 }
3182
3183
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version<4)
3184 {
3185 3 set_bit(quest_rules,10,0);
3186 3 }
3187
3188
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version<5)
3189 {
3190 3 set_bit(quest_rules,27,0);
3191 3 }
3192
3193
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version<6)
3194 {
3195 3 set_bit(quest_rules,46,0);
3196 3 }
3197
3198
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version<7) // January 2008
3199 {
3200 3 set_bit(quest_rules,qr_HEARTSREQUIREDFIX,0);
3201 3 set_bit(quest_rules,qr_PUSHBLOCKCSETFIX,1);
3202 3 }
3203
3204
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 96 times.
99 if(s_version<8)
3205 {
3206 3 set_bit(quest_rules, 12, 0);
3207 3 }
3208 else
3209 {
3210 96 set_bit(deprecated_rules, 12, 0);
3211 }
3212
3213
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version<9) // October 2008
3214 {
3215 3 set_bit(quest_rules,qr_NOROPE2FLASH_DEP,0);
3216 3 set_bit(quest_rules,qr_NOBUBBLEFLASH_DEP,0);
3217 3 set_bit(quest_rules,qr_GHINI2BLINK_DEP,0);
3218 3 set_bit(quest_rules,qr_PHANTOMGHINI2_DEP,0);
3219 3 }
3220
3221
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version<10) // December 2008
3222 {
3223 3 set_bit(quest_rules,qr_NOCLOCKS_DEP,0);
3224 3 set_bit(quest_rules, qr_ALLOW10RUPEEDROPS_DEP,0);
3225 3 }
3226
3227
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version<11) // April 2009
3228 {
3229 3 set_bit(quest_rules,qr_SLOWENEMYANIM_DEP,0);
3230 3 }
3231
3232
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version<12) // December 2009
3233 {
3234 3 set_bit(quest_rules,qr_BRKBLSHLDS_DEP,0);
3235 3 set_bit(quest_rules, qr_OLDTRIBBLES_DEP,0);
3236 3 }
3237
3238 //if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 24))
3239
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version < 13)
3240 {
3241 3 set_bit(quest_rules,qr_SHOPCHEAT, 1);
3242 3 }
3243
3244 // Not entirely sure this is the best place for this...
3245 //2.50.2 bitmap offset fix
3246 99 memset(extra_rules, 0, EXTRARULES_SIZE);
3247
6/6
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 74 times.
✓ Branch 3 taken 22 times.
✓ Branch 4 taken 27 times.
✓ Branch 5 taken 47 times.
99 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
3248 {
3249 30 set_bit(extra_rules, er_BITMAPOFFSET, 1);
3250 30 set_bit(quest_rules, qr_BITMAPOFFSETFIX, 1);
3251 30 }
3252 //required because quest templates also used this bit, although
3253 //it never did anything, before. -Z
3254
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 74 times.
99 if ( tempheader.zelda_version == 0x250 )
3255 {
3256
5/6
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 50 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✓ Branch 5 taken 35 times.
74 if( tempheader.build == 29 || tempheader.build == 30 || tempheader.build == 31 )
3257 {
3258 39 set_bit(extra_rules, er_BITMAPOFFSET, 0);
3259 39 set_bit(quest_rules, qr_BITMAPOFFSETFIX, 0);
3260 39 }
3261 74 }
3262
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if ( tempheader.zelda_version == 0x254 )
3263 {
3264 set_bit(extra_rules, er_BITMAPOFFSET, 0);
3265 set_bit(quest_rules, qr_BITMAPOFFSETFIX, 0);
3266 }
3267
3/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
99 if ( tempheader.zelda_version == 0x255 && tempheader.build < 42 ) //QR was added to 255 in this build.
3268 {
3269 set_bit(extra_rules, er_BITMAPOFFSET, 0);
3270 set_bit(quest_rules, qr_BITMAPOFFSETFIX, 0);
3271 }
3272 //optimise fast drawing for older versions.
3273
4/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
99 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3274 {
3275 77 set_bit(quest_rules, qr_OLDSPRITEDRAWS, 1);
3276 77 }
3277 //Old eweapon->Parent (was added in 2.54, Alpha 19)
3278 //The change was made in build 43, but I'm setting this to < 42, because quests made in 42 would benefit from this change, and
3279 //older quests can set the rule by hand. We need a new qst.dat again.
3280
4/6
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✓ Branch 3 taken 77 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
99 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3281 {
3282 set_bit(quest_rules, qr_OLDEWPNPARENT, 1);
3283 }
3284
4/6
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✓ Branch 3 taken 77 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
99 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3285 {
3286 set_bit(quest_rules, qr_OLDCREATEBITMAP_ARGS, 1);
3287 }
3288
4/6
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✓ Branch 3 taken 77 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
99 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 45) )
3289 {
3290 set_bit(quest_rules, qr_OLDQUESTMISC, 1);
3291 }
3292
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if ( tempheader.zelda_version < 0x254 )
3293 {
3294 77 set_bit(quest_rules, qr_OLDCREATEBITMAP_ARGS, 0);
3295 77 set_bit(quest_rules, qr_OLDEWPNPARENT, 0);
3296 77 set_bit(quest_rules, qr_OLDQUESTMISC, 0);
3297 77 }
3298
3299 //item scripts continue to run
3300
4/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
99 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3301 {
3302 77 set_bit(quest_rules, qr_ITEMSCRIPTSKEEPRUNNING, 0);
3303 77 set_bit(quest_rules, qr_SCRIPTSRUNINHEROSTEPFORWARD, 0);
3304 77 set_bit(quest_rules, qr_FIXSCRIPTSDURINGSCROLLING, 0);
3305 77 set_bit(quest_rules, qr_SCRIPTDRAWSINWARPS, 0);
3306 77 set_bit(quest_rules, qr_DYINGENEMYESDONTHURTHERO, 0);
3307 77 set_bit(quest_rules, qr_OUTOFBOUNDSENEMIES, 0);
3308 77 set_bit(quest_rules, qr_SPRITEXY_IS_FLOAT, 0);
3309 77 }
3310
3311
4/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
99 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3312 {
3313 77 set_bit(quest_rules, qr_CLEARINITDONSCRIPTCHANGE, 1);
3314 77 }
3315
4/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
99 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3316 {
3317 77 set_bit(quest_rules, qr_TRACESCRIPTIDS, 0);
3318 77 set_bit(quest_rules, qr_SCRIPT_FRIENDLY_ENEMY_TYPES, 1);
3319 77 set_bit(quest_rules, qr_PARSER_BOOL_TRUE_DECIMAL, 1);
3320 77 set_bit(quest_rules,qr_PARSER_250DIVISION,1);
3321 77 set_bit(quest_rules,qr_PARSER_BOOL_TRUE_DECIMAL,1);
3322 77 set_bit(quest_rules,qr_PARSER_TRUE_INT_SIZE,0);
3323 77 set_bit(quest_rules,qr_PARSER_FORCE_INLINE,0);
3324 77 set_bit(quest_rules,qr_PARSER_BINARY_32BIT,0);
3325
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 1 times.
77 if ( get_bit(quest_rules, qr_SELECTAWPN) )
3326 {
3327 1 set_bit(quest_rules,qr_NO_L_R_BUTTON_INVENTORY_SWAP,1);
3328 //In < 2.55a27, if you had an A+B subscreen, L and R didn't shift through inventory.
3329 //Now they **do**, unless you disable that behaviour.
3330 //For the sake of compatibility, old quests with the A+B subscreen rule enabed
3331 //now enable the disable L/R item swap on load.
3332 1 }
3333
3334 77 }
3335
4/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
99 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3336 {
3337 //Compatibility: Setting the hero's action to rafting was previously disallowed, though legal for scripts to attempt.
3338 77 set_bit(quest_rules, qr_DISALLOW_SETTING_RAFTING, 1);
3339 //Compatibility: The calculation for when to loop an animation did not factor in ASkipY correctly, resulting in
3340 //animations ending earlier than they should.
3341 77 set_bit(quest_rules, qr_BROKEN_ASKIP_Y_FRAMES, 1);
3342 //Enemies would ignore solidity on the top half of combos
3343 77 set_bit(quest_rules, qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY, 1);
3344 //Ceiling collison was a bit wonky, including hitting your head before you are near the ceiling or clipping into it slightly.
3345 77 set_bit(quest_rules, qr_OLD_SIDEVIEW_CEILING_COLLISON, 1);
3346 //If an itemdata had a 'frames' of 0, items created of that data would ignore all changes to 'frames'
3347 77 set_bit(quest_rules, qr_0AFRAME_ITEMS_IGNORE_AFRAME_CHANGES, 1);
3348 //Collision used some odd calculations before, and enemies could not be hit back into the top row or left column
3349 77 set_bit(quest_rules, qr_OLD_ENEMY_KNOCKBACK_COLLISION, 1);
3350 77 }
3351
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if ( tempheader.zelda_version < 0x255 )
3352 {
3353 77 set_bit(quest_rules, qr_NOFFCWAITDRAW, 1);
3354 77 set_bit(quest_rules, qr_NOITEMWAITDRAW, 1);
3355 77 set_bit(quest_rules, qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3356 77 set_bit(quest_rules, qr_OLD_INIT_SCRIPT_TIMING, 1);
3357 //set_bit(quest_rules, qr_DO_NOT_DEALLOCATE_INIT_AND_SAVELOAD_ARRAYS, 1);
3358 77 }
3359
4/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
99 if ( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 48 ) )
3360 {
3361 77 set_bit(quest_rules, qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3362 77 }
3363
4/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
99 if( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 52 ) )
3364 {
3365 77 set_bit(quest_rules, qr_OLD_PRINTF_ARGS, 1);
3366 77 }
3367
3368
3369
4/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
99 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 54) )
3370 {
3371 77 set_bit(quest_rules, qr_BROKEN_RING_POWER, 1);
3372 77 }
3373
4/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
99 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 56) )
3374 {
3375 77 set_bit(quest_rules, qr_NO_OVERWORLD_MAP_CHARTING, 1);
3376 77 }
3377
4/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
99 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 57) )
3378 {
3379 77 set_bit(quest_rules, qr_DUNGEONS_USE_CLASSIC_CHARTING, 1);
3380 77 }
3381
4/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
99 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 58) )
3382 {
3383 //Rule used to be 'qr_SETXYBUTTONITEMS', now split.
3384
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(get_bit(quest_rules,qr_SET_XBUTTON_ITEMS))
3385 set_bit(quest_rules,qr_SET_YBUTTON_ITEMS,1);
3386 77 }
3387
4/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
99 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 59) )
3388 {
3389 77 set_bit(quest_rules,qr_ALLOW_EDITING_COMBO_0,1);
3390 77 }
3391
4/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
99 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 60) )
3392 {
3393 77 set_bit(quest_rules,qr_OLD_CHEST_COLLISION,1);
3394 77 }
3395
3396
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if ( tempheader.zelda_version < 0x254 )
3397 {
3398 77 set_bit(quest_rules, qr_250WRITEEDEFSCRIPT, 1);
3399 77 }
3400 //Sideview spikes in 2.50.0
3401
6/6
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 74 times.
✓ Branch 3 taken 22 times.
✓ Branch 4 taken 22 times.
✓ Branch 5 taken 52 times.
99 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<27)) //2.50.1RC3
3402 {
3403 25 set_bit(quest_rules, qr_OLDSIDEVIEWSPIKES, 1);
3404 25 }
3405 //more 2.50 fixes -Z
3406
6/6
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 74 times.
✓ Branch 3 taken 22 times.
✓ Branch 4 taken 51 times.
✓ Branch 5 taken 23 times.
99 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<31))
3407 {
3408 54 set_bit(quest_rules, qr_MELEEMAGICCOST, 0);
3409 54 set_bit(quest_rules, qr_GANONINTRO, 0); //This will get flipped later on in the compatrule 11 check. That's why it's turning it off.
3410 54 set_bit(quest_rules, qr_OLDMIRRORCOMBOS, 1);
3411 54 set_bit(quest_rules, qr_BROKENBOOKCOST, 1);
3412 54 set_bit(quest_rules, qr_BROKENCHARINTDRAWING, 1);
3413
3414 54 }
3415
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
99 if(tempheader.zelda_version == 0x254 && tempheader.build<41)
3416 {
3417 //set_bit(quest_rules,qr_MELEEMAGICCOST, get_bit(extra_rules,er_MAGICCOSTSWORD));
3418 set_bit(quest_rules,qr_MELEEMAGICCOST, 1);
3419 }
3420
3421
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(tempheader.zelda_version < 0x193)
3422 {
3423 set_bit(quest_rules, qr_SHORTDGNWALK, 1);
3424 }
3425
3426
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(tempheader.zelda_version < 0x255)
3427 {
3428 77 set_bit(quest_rules, qr_OLDINFMAGIC, 1);
3429 77 }
3430
3431
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if((tempheader.zelda_version < 0x250)) //2.10 and earlier allowed the triforce to Warp Player out of Item Cellars in Dungeons. -Z (15th March, 2019 )
3432 {
3433 3 set_bit(quest_rules,qr_SIDEVIEWTRIFORCECELLAR,1);
3434 3 }
3435
3436
4/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
99 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3437 {
3438 77 set_bit(quest_rules,qr_OLD_F6,1);
3439 77 }
3440
4/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
99 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 49) )
3441 {
3442 77 set_bit(quest_rules,qr_NO_OVERWRITING_HOPPING,1);
3443 77 }
3444
4/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
99 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3445 {
3446 77 set_bit(quest_rules,qr_STRING_FRAME_OLD_WIDTH_HEIGHT,1);
3447 77 }
3448
4/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
99 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 53) )
3449 {
3450 77 set_bit(quest_rules,qr_BROKEN_OVERWORLD_MINIMAP,1);
3451 77 }
3452 //}
3453
3454
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 1)
3455 {
3456 //Enemies->Secret only affects flag 16-31
3457 77 set_bit(quest_rules,qr_ENEMIES_SECRET_ONLY_16_31,1);
3458 77 }
3459
3460
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 2)
3461 {
3462 //Old CSet2 Handling
3463 77 set_bit(quest_rules,qr_OLDCS2,1);
3464 77 }
3465
3466
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 3)
3467 {
3468 //Hardcoded Shadow/Spawn/Death anim frames
3469 77 set_bit(quest_rules,qr_HARDCODED_ENEMY_ANIMS,1);
3470 77 }
3471
3472
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 4)
3473 {
3474 //Hardcoded Shadow/Spawn/Death anim frames
3475 77 set_bit(quest_rules,qr_OLD_ITEMDATA_SCRIPT_TIMING,1);
3476 77 }
3477
3478
4/4
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 22 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 74 times.
99 if(compatrule_version < 5 && tempheader.zelda_version >= 0x250)
3479 {
3480 //Hardcoded Shadow/Spawn/Death anim frames
3481 74 set_bit(quest_rules,qr_NO_LANMOLA_RINGLEADER,1);
3482 74 }
3483
3484
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 6)
3485 {
3486 //Step->Secret (Temp) only affects flag 16-31
3487 77 set_bit(quest_rules,qr_STEPTEMP_SECRET_ONLY_16_31,1);
3488 77 }
3489
3490
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 7)
3491 {
3492 //'Hit All Triggers->Perm Secret' doesn't trigger temp secrets
3493 77 set_bit(quest_rules,qr_ALLTRIG_PERMSEC_NO_TEMP,1);
3494 77 }
3495
3496
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 8)
3497 {
3498 //Hardcoded LItem/Bomb/Clock/Magic Tile Mods
3499 77 set_bit(quest_rules,qr_HARDCODED_LITEM_LTMS,1);
3500 77 }
3501
3502
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 9)
3503 {
3504 //Hardcoded BS Patras
3505 77 set_bit(quest_rules,qr_HARDCODED_BS_PATRA,1);
3506 //Hardcoded Patra Inner Eye offsets
3507 77 set_bit(quest_rules,qr_PATRAS_USE_HARDCODED_OFFSETS,1);
3508 //Broken 'Big enemy' animation style
3509 77 set_bit(quest_rules,qr_BROKEN_BIG_ENEMY_ANIMATION,1);
3510 //Broken Attribute 31/32
3511 77 set_bit(quest_rules,qr_BROKEN_ATTRIBUTE_31_32,1);
3512 77 }
3513
3514
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 10)
3515 {
3516 //Shared candle use limits
3517 77 set_bit(quest_rules,qr_CANDLES_SHARED_LIMIT,1);
3518 77 }
3519
3520
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 11)
3521 {
3522 //No cross-screen return points
3523 77 set_bit(quest_rules,qr_OLD_RESPAWN_POINTS,1);
3524 77 }
3525
3526
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 12)
3527 {
3528 //Old fire trail duration
3529 77 set_bit(quest_rules,qr_OLD_FLAMETRAIL_DURATION,1);
3530 //Old Intro String in Ganon Room Behavior
3531
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(get_bit(quest_rules,qr_GANONINTRO)) set_bit(quest_rules,qr_GANONINTRO,0);
3532 77 else set_bit(quest_rules,qr_GANONINTRO,1);
3533 77 }
3534
3535
3/4
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 22 times.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
99 if(compatrule_version < 13 && tempheader.zelda_version >= 0x255)
3536 {
3537 //ANone doesn't reset to originaltile
3538 set_bit(quest_rules,qr_ANONE_NOANIM,1);
3539 }
3540
3541
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 14)
3542 {
3543 //Old Bridge Combo Behavior
3544 77 set_bit(quest_rules,qr_OLD_BRIDGE_COMBOS,1);
3545 77 }
3546
3547
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 15)
3548 {
3549 //Broken Z3 Animation
3550 77 set_bit(quest_rules,qr_BROKEN_Z3_ANIMATION,1);
3551 77 }
3552
3553
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 16)
3554 {
3555 //Old Enemy Tile Behavior with Animation (None) Enemies
3556 77 set_bit(quest_rules,qr_OLD_TILE_INITIALIZATION,1);
3557 77 }
3558
3559
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 17)
3560 {
3561 //Old Quake/DrawYOffset behavior
3562 //set_bit(quest_rules,qr_OLD_DRAWOFFSET,1);
3563 //I'm leaving this commented cause I doubt it'll break anything and I think the bugfix might be appreciated in older versions.
3564 //On the offchance that it *does* break old quests, fixing it is as simple as uncommenting the set_bit above.
3565 77 }
3566
3567
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 18)
3568 {
3569 //Broken DrawScreen Derivative Functions
3570 77 set_bit(quest_rules,qr_BROKEN_DRAWSCREEN_FUNCTIONS,1);
3571 //Scrolling Cancels Charge
3572 77 set_bit(quest_rules,qr_SCROLLING_KILLS_CHARGE,1);
3573 77 }
3574
3575
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 19)
3576 {
3577 //Broken Enemy Item Carrying with Large Enemies
3578 77 set_bit(quest_rules,qr_BROKEN_ITEM_CARRYING,1);
3579 77 }
3580
3581
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 20)
3582 {
3583 77 set_bit(quest_rules,qr_CUSTOMWEAPON_IGNORE_COST,1);
3584 77 }
3585
3586
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 21)
3587 {
3588 77 set_bit(quest_rules,qr_LEEVERS_DONT_OBEY_STUN,1);
3589 77 set_bit(quest_rules,qr_GANON_CANT_SPAWN_ON_CONTINUE,1);
3590 77 set_bit(quest_rules,qr_WIZZROBES_DONT_OBEY_STUN,1);
3591 77 set_bit(quest_rules,qr_OLD_BUG_NET,1);
3592 77 set_bit(quest_rules,qr_MANHANDLA_BLOCK_SFX,1);
3593 77 }
3594
3595
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 22)
3596 {
3597 77 set_bit(quest_rules,qr_BROKEN_KEEPOLD_FLAG,1);
3598 77 }
3599
3600
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 23)
3601 {
3602 77 set_bit(quest_rules,qr_OLD_HALF_MAGIC,1);
3603 77 }
3604
3605
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 24)
3606 {
3607 77 set_bit(quest_rules,qr_WARPS_RESTART_DMAPSCRIPT,1);
3608 77 set_bit(quest_rules,qr_DMAP_0_CONTINUE_BUG,1);
3609 77 }
3610
3611
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 25)
3612 {
3613
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if (get_bit(quest_rules, qr_OLD_FAIRY_LIMIT)) set_bit(quest_rules,qr_OLD_FAIRY_LIMIT,0);
3614 77 else set_bit(quest_rules,qr_OLD_FAIRY_LIMIT,1);
3615 77 set_bit(quest_rules,qr_OLD_SCRIPTED_KNOCKBACK,1);
3616 77 }
3617
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 26)
3618 {
3619 77 set_bit(quest_rules,qr_OLD_KEESE_Z_AXIS,1);
3620 77 set_bit(quest_rules,qr_POLVIRE_NO_SHADOW,1);
3621 77 set_bit(quest_rules,qr_SUBSCR_OLD_SELECTOR,1);
3622 77 }
3623
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 27) //Noticed some junk data in the QR array...
3624 {
3625
2/2
✓ Branch 0 taken 23177 times.
✓ Branch 1 taken 77 times.
23254 for(auto q = qr_POLVIRE_NO_SHADOW+1; q < qr_PARSER_250DIVISION; ++q)
3626 23177 set_bit(quest_rules,q,0);
3627
2/2
✓ Branch 0 taken 8624 times.
✓ Branch 1 taken 77 times.
8701 for(auto q = qr_COMBODATA_INITD_MULT_TENK+1; q < QUESTRULES_NEW_SIZE*8; ++q)
3628 8624 set_bit(quest_rules,q,0);
3629 //This should nuke any remaining junk data... not sure if it affected anything previous. -Em
3630 77 }
3631
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 79 times.
99 if(compatrule_version < 28)
3632 {
3633 79 set_bit(quest_rules,qr_SUBSCR_BACKWARDS_ID_ORDER,1);
3634 79 }
3635
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 79 times.
99 if(compatrule_version < 29)
3636 {
3637 79 set_bit(quest_rules,qr_OLD_LOCKBLOCK_COLLISION,1);
3638 79 }
3639
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 79 times.
99 if(compatrule_version < 30)
3640 {
3641 79 set_bit(quest_rules,qr_DECO_2_YOFFSET,1);
3642 79 set_bit(quest_rules,qr_SCREENSTATE_80s_BUG,1);
3643 79 }
3644
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 79 times.
99 if(compatrule_version < 31)
3645 {
3646 79 set_bit(quest_rules,qr_GOHMA_UNDAMAGED_BUG,1);
3647 79 set_bit(quest_rules,qr_FFCPRELOAD_BUGGED_LOAD,1);
3648 79 }
3649
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 79 times.
99 if(compatrule_version < 32)
3650 {
3651 79 set_bit(quest_rules,qr_BROKEN_GETPIXEL_VALUE,1);
3652 79 }
3653
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 79 times.
99 if(compatrule_version < 33)
3654 {
3655 79 set_bit(quest_rules,qr_NO_LIFT_SPRITE,1);
3656 79 }
3657
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 86 times.
99 if(compatrule_version < 34)
3658 {
3659 86 set_bit(quest_rules,qr_OLD_SIDEVIEW_LANDING_CODE,1);
3660 86 set_bit(quest_rules,qr_OLD_FFC_SPEED_CAP,1);
3661 86 set_bit(quest_rules,qr_OLD_FFC_FUNCTIONALITY,1);
3662 86 set_bit(quest_rules,qr_OLD_WIZZROBE_SUBMERGING,1);
3663 86 }
3664
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 88 times.
99 if(compatrule_version < 35)
3665 {
3666 // Leaving this commented for now, might need to enable later -Em
3667 // set_bit(quest_rules,qr_ZS_NO_NEG_ARRAY,1);
3668 88 }
3669
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 88 times.
99 if(compatrule_version < 36)
3670 {
3671 88 set_bit(quest_rules,qr_OLD_SHALLOW_SFX,1);
3672 88 }
3673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(compatrule_version < 37)
3674 {
3675 99 set_bit(quest_rules,qr_SPARKLES_INHERIT_PROPERTIES,1);
3676 99 }
3677
3678 //always set
3679 99 set_bit(quest_rules,qr_ANIMATECUSTOMWEAPONS,0);
3680
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if (s_version < 16) set_bit(quest_rules,qr_BROKEN_HORIZONTAL_WEAPON_ANIM,1);
3681
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata==true)
3682 {
3683 99 memcpy(Header, &tempheader, sizeof(tempheader));
3684 99 }
3685 99 return 0;
3686 99 }
3687
3688 816980 void init_msgstr(MsgStr *str)
3689 {
3690 816980 str->s = "";
3691 816980 str->s.shrink_to_fit();
3692 816980 str->nextstring=0;
3693 816980 str->tile=0;
3694 816980 str->cset=0;
3695 816980 str->trans=false;
3696 816980 str->font=font_zfont;
3697 816980 str->y=32;
3698 816980 str->sfx=18;
3699 816980 str->listpos=0;
3700 816980 str->x=24;
3701 816980 str->w=get_bit(quest_rules,qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 24*8 : 26*8;
3702 816980 str->h=get_bit(quest_rules,qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 3*8 : 5*8;
3703 816980 str->hspace=0;
3704 816980 str->vspace=0;
3705 816980 str->stringflags=0;
3706 816980 str->margins[up] = 8;
3707 816980 str->margins[down] = 0;
3708 816980 str->margins[left] = 8;
3709 816980 str->margins[right] = 0;
3710 816980 str->portrait_tile = 0;
3711 816980 str->portrait_cset = 0;
3712 816980 str->portrait_x = 0;
3713 816980 str->portrait_y = 0;
3714 816980 str->portrait_tw = 1;
3715 816980 str->portrait_th = 1;
3716 816980 str->shadow_type = 0;
3717 816980 str->shadow_color = 0;
3718 816980 str->drawlayer = 6;
3719 816980 }
3720
3721 99 void init_msgstrings(int32_t start, int32_t end)
3722 {
3723
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
99 if(end <= start || end-start > msg_strings_size)
3724 return;
3725
3726
2/2
✓ Branch 0 taken 811008 times.
✓ Branch 1 taken 99 times.
811107 for(int32_t i=start; i<end; i++)
3727 {
3728 811008 init_msgstr(&MsgStrings[i]);
3729 811008 MsgStrings[i].listpos=i;
3730 811008 }
3731
3732
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(start==0)
3733 {
3734 99 MsgStrings[0].s = "(None)";
3735 99 MsgStrings[0].listpos = 0;
3736 99 }
3737 99 }
3738
3739 99 int32_t readstrings(PACKFILE *f, zquestheader *Header, bool keepdata)
3740 {
3741 99 MsgStr tempMsgString;
3742
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 init_msgstr(&tempMsgString);
3743
3744 99 word temp_msg_count=0;
3745 word temp_expansion[16];
3746 99 memset(temp_expansion, 0, 16*sizeof(word));
3747 99 char buf[8193] = {0};
3748
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(Header->zelda_version < 0x193)
3749 {
3750 byte tempbyte;
3751 int32_t strings_to_read=0;
3752 set_bit(quest_rules,qr_OLD_STRING_EDITOR_MARGINS,true);
3753 if((Header->zelda_version < 0x192)||
3754 ((Header->zelda_version == 0x192)&&(Header->build<31)))
3755 {
3756 strings_to_read=128;
3757 temp_msg_count=Header->old_str_count;
3758
3759 // Some sort of string count corruption seems to be common in old quests
3760 if(temp_msg_count>128)
3761 {
3762 temp_msg_count=128;
3763 }
3764 }
3765 else if((Header->zelda_version == 0x192)&&(Header->build<140))
3766 {
3767 strings_to_read=255;
3768 temp_msg_count=Header->old_str_count;
3769 }
3770 else
3771 {
3772 if(!p_igetw(&temp_msg_count,f,true))
3773 {
3774 return qe_invalid;
3775 }
3776
3777 strings_to_read=temp_msg_count;
3778
3779 if(temp_msg_count >= msg_strings_size)
3780 {
3781 Z_message("Reallocating string buffer...\n");
3782
3783 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3784 // return qe_nomem;
3785
3786 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3787 delete[] MsgStrings;
3788 MsgStrings = new MsgStr[MAXMSGS];
3789 msg_strings_size = MAXMSGS;
3790 for(auto q = 0; q < msg_strings_size; ++q)
3791 {
3792 MsgStrings[q].clear();
3793 }
3794 }
3795 }
3796
3797 //reset the message strings
3798 if(keepdata)
3799 {
3800 init_msgstrings(0,msg_strings_size);
3801 }
3802
3803 for(int32_t x=0; x<strings_to_read; x++)
3804 {
3805 init_msgstr(&tempMsgString);
3806
3807 if(!pfread(buf,73,f,true))
3808 {
3809 return qe_invalid;
3810 }
3811
3812 buf[74] = '\0';
3813 tempMsgString.s = buf;
3814
3815 if(!p_getc(&tempbyte,f,true))
3816 {
3817 return qe_invalid;
3818 }
3819
3820 if((Header->zelda_version < 0x192)||
3821 ((Header->zelda_version == 0x192)&&(Header->build<148)))
3822 {
3823 tempMsgString.nextstring=tempbyte?x+1:0;
3824
3825 if(!p_getc(&tempbyte,f,true))
3826 {
3827 return qe_invalid;
3828 }
3829
3830 if(!p_getc(&tempbyte,f,true))
3831 {
3832 return qe_invalid;
3833 }
3834 }
3835 else
3836 {
3837 if(!p_igetw(&tempMsgString.nextstring,f,true))
3838 {
3839 return qe_invalid;
3840 }
3841
3842 if(!pfread(temp_expansion,32,f,true))
3843 {
3844 return qe_invalid;
3845 }
3846 }
3847
3848 if(keepdata==true)
3849 {
3850 MsgStrings[x] = tempMsgString;
3851 }
3852 }
3853 }
3854 else
3855 {
3856 int32_t dummy_int;
3857 word s_version;
3858 word s_cversion;
3859
3860 //section version info
3861
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_igetw(&s_version,f,true))
3862 {
3863 return qe_invalid;
3864 }
3865
3866 99 FFCore.quest_format[vStrings] = s_version;
3867
3868
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_igetw(&s_cversion,f,true))
3869 {
3870 return qe_invalid;
3871 }
3872
3873 //al_trace("Strings version %d\n", s_version);
3874 //section size
3875
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_igetl(&dummy_int,f,true))
3876 {
3877 return qe_invalid;
3878 }
3879
3880 //finally... section data
3881
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_igetw(&temp_msg_count,f,true))
3882 {
3883 return qe_invalid;
3884 }
3885
3886
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(temp_msg_count >= msg_strings_size)
3887 {
3888 Z_message("Reallocating string buffer...\n");
3889
3890 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3891 // return qe_nomem;
3892 delete[] MsgStrings;
3893 MsgStrings = new MsgStr[MAXMSGS];
3894 msg_strings_size = MAXMSGS;
3895 for(auto q = 0; q < msg_strings_size; ++q)
3896 {
3897 MsgStrings[q].clear();
3898 }
3899 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3900 }
3901
3902 //reset the message strings
3903
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(keepdata)
3904 {
3905
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 22 times.
99 if(s_version < 7)
3906
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 set_bit(quest_rules,qr_OLD_STRING_EDITOR_MARGINS,true);
3907
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 init_msgstrings(0,msg_strings_size);
3908 99 }
3909
3910 99 int32_t string_length=(s_version<2)?73:145;
3911
3912
2/2
✓ Branch 0 taken 5873 times.
✓ Branch 1 taken 99 times.
5972 for(int32_t i=0; i<temp_msg_count; i++)
3913 {
3914
1/2
✓ Branch 0 taken 5873 times.
✗ Branch 1 not taken.
5873 init_msgstr(&tempMsgString);
3915
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 5013 times.
5873 if(s_version > 8)
3916 {
3917
2/4
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 860 times.
✗ Branch 3 not taken.
860 if(!p_igetl(&string_length,f,true))
3918 {
3919 return qe_invalid;
3920 }
3921 860 }
3922
2/2
✓ Branch 0 taken 5735 times.
✓ Branch 1 taken 138 times.
5873 if (string_length > 0)
3923 {
3924
2/4
✓ Branch 0 taken 5735 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5735 times.
✗ Branch 3 not taken.
5735 if (!pfread(buf, string_length, f, true))
3925 {
3926 return qe_invalid;
3927 }
3928 5735 }
3929 else
3930 {
3931 138 buf[0] = 0;
3932 }
3933
3934
2/4
✓ Branch 0 taken 5873 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5873 times.
✗ Branch 3 not taken.
5873 if(!p_igetw(&tempMsgString.nextstring,f,true))
3935 {
3936 return qe_invalid;
3937 }
3938
3939
2/2
✓ Branch 0 taken 516 times.
✓ Branch 1 taken 5357 times.
5873 if(s_version<2)
3940 {
3941 516 buf[72] = '\0';
3942
1/2
✓ Branch 0 taken 516 times.
✗ Branch 1 not taken.
516 tempMsgString.s = buf;
3943 516 }
3944 else
3945 {
3946 // June 2008: A bug corrupted the last 4 chars of a string.
3947 // Discard these.
3948
1/2
✓ Branch 0 taken 5357 times.
✗ Branch 1 not taken.
5357 if(s_version<3)
3949 {
3950 for(int32_t j=140; j<144; j++)
3951 {
3952 buf[j] = '\0';
3953 }
3954 }
3955
1/2
✓ Branch 0 taken 5357 times.
✗ Branch 1 not taken.
5357 if(string_length > 8192) string_length = 8192;
3956 5357 buf[string_length]='\0'; //Force-terminate
3957
1/2
✓ Branch 0 taken 5357 times.
✗ Branch 1 not taken.
5357 tempMsgString.s = buf;
3958
3959
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 4497 times.
5357 if ( s_version >= 6 )
3960 {
3961
2/4
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 860 times.
✗ Branch 3 not taken.
860 if(!p_igetl(&tempMsgString.tile,f,true))
3962 {
3963 return qe_invalid;
3964 }
3965 860 }
3966 else
3967 {
3968
2/4
✓ Branch 0 taken 4497 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4497 times.
✗ Branch 3 not taken.
4497 if(!p_igetw(&tempMsgString.tile,f,true))
3969 {
3970 return qe_invalid;
3971 }
3972 }
3973
3974
2/4
✓ Branch 0 taken 5357 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5357 times.
✗ Branch 3 not taken.
5357 if(!p_getc(&tempMsgString.cset,f,true))
3975 {
3976 return qe_invalid;
3977 }
3978
3979 byte dummy_char;
3980
3981
2/4
✓ Branch 0 taken 5357 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5357 times.
✗ Branch 3 not taken.
5357 if(!p_getc(&dummy_char,f,true)) // trans is stored as a char...
3982 {
3983 return qe_invalid;
3984 }
3985
3986 5357 tempMsgString.trans=dummy_char!=0;
3987
3988
2/4
✓ Branch 0 taken 5357 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5357 times.
✗ Branch 3 not taken.
5357 if(!p_getc(&tempMsgString.font,f,true))
3989 {
3990 return qe_invalid;
3991 }
3992
3993
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5357 times.
5357 if(s_version < 5)
3994 {
3995 if(!p_getc(&tempMsgString.y,f,true))
3996 {
3997 return qe_invalid;
3998 }
3999 }
4000 else
4001 {
4002
2/4
✓ Branch 0 taken 5357 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5357 times.
✗ Branch 3 not taken.
5357 if(!p_igetw(&tempMsgString.x,f,true))
4003 {
4004 return qe_invalid;
4005 }
4006
4007
2/4
✓ Branch 0 taken 5357 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5357 times.
✗ Branch 3 not taken.
5357 if(!p_igetw(&tempMsgString.y,f,true))
4008 {
4009 return qe_invalid;
4010 }
4011
4012
2/4
✓ Branch 0 taken 5357 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5357 times.
✗ Branch 3 not taken.
5357 if(!p_igetw(&tempMsgString.w,f,true))
4013 {
4014 return qe_invalid;
4015 }
4016
4017
2/4
✓ Branch 0 taken 5357 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5357 times.
✗ Branch 3 not taken.
5357 if(!p_igetw(&tempMsgString.h,f,true))
4018 {
4019 return qe_invalid;
4020 }
4021
4022
2/4
✓ Branch 0 taken 5357 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5357 times.
✗ Branch 3 not taken.
5357 if(!p_getc(&tempMsgString.hspace,f,true))
4023 {
4024 return qe_invalid;
4025 }
4026
4027
2/4
✓ Branch 0 taken 5357 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5357 times.
✗ Branch 3 not taken.
5357 if(!p_getc(&tempMsgString.vspace,f,true))
4028 {
4029 return qe_invalid;
4030 }
4031
4032
2/4
✓ Branch 0 taken 5357 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5357 times.
✗ Branch 3 not taken.
5357 if(!p_getc(&tempMsgString.stringflags,f,true))
4033 {
4034 return qe_invalid;
4035 }
4036 }
4037
4038
2/2
✓ Branch 0 taken 4497 times.
✓ Branch 1 taken 860 times.
5357 if(s_version >= 7)
4039 {
4040
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 3440 times.
4300 for(int32_t q = 0; q < 4; ++q)
4041 {
4042
2/4
✓ Branch 0 taken 3440 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3440 times.
✗ Branch 3 not taken.
3440 if(!p_getc(&tempMsgString.margins[q],f,true))
4043 {
4044 return qe_invalid;
4045 }
4046 3440 }
4047
4048
2/4
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 860 times.
✗ Branch 3 not taken.
860 if(!p_igetl(&tempMsgString.portrait_tile,f,true))
4049 {
4050 return qe_invalid;
4051 }
4052
4053
2/4
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 860 times.
✗ Branch 3 not taken.
860 if(!p_getc(&tempMsgString.portrait_cset,f,true))
4054 {
4055 return qe_invalid;
4056 }
4057
4058
2/4
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 860 times.
✗ Branch 3 not taken.
860 if(!p_getc(&tempMsgString.portrait_x,f,true))
4059 {
4060 return qe_invalid;
4061 }
4062
4063
2/4
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 860 times.
✗ Branch 3 not taken.
860 if(!p_getc(&tempMsgString.portrait_y,f,true))
4064 {
4065 return qe_invalid;
4066 }
4067
4068
2/4
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 860 times.
✗ Branch 3 not taken.
860 if(!p_getc(&tempMsgString.portrait_tw,f,true))
4069 {
4070 return qe_invalid;
4071 }
4072
4073
2/4
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 860 times.
✗ Branch 3 not taken.
860 if(!p_getc(&tempMsgString.portrait_th,f,true))
4074 {
4075 return qe_invalid;
4076 }
4077 860 }
4078
4079
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 4497 times.
5357 if(s_version >= 8)
4080 {
4081
2/4
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 860 times.
✗ Branch 3 not taken.
860 if(!p_getc(&tempMsgString.shadow_type,f,true))
4082 {
4083 return qe_invalid;
4084 }
4085
4086
2/4
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 860 times.
✗ Branch 3 not taken.
860 if(!p_getc(&tempMsgString.shadow_color,f,true))
4087 {
4088 return qe_invalid;
4089 }
4090 860 }
4091
4092
2/2
✓ Branch 0 taken 743 times.
✓ Branch 1 taken 4614 times.
5357 if(s_version >= 10)
4093 {
4094
2/4
✓ Branch 0 taken 743 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 743 times.
✗ Branch 3 not taken.
743 if(!p_getc(&tempMsgString.drawlayer,f,true))
4095 {
4096 return qe_invalid;
4097 }
4098 743 }
4099
4100
2/4
✓ Branch 0 taken 5357 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5357 times.
✗ Branch 3 not taken.
5357 if(!p_getc(&tempMsgString.sfx,f,true))
4101 {
4102 return qe_invalid;
4103 }
4104
4105
1/2
✓ Branch 0 taken 5357 times.
✗ Branch 1 not taken.
5357 if(s_version>3)
4106 {
4107
2/4
✓ Branch 0 taken 5357 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5357 times.
✗ Branch 3 not taken.
5357 if(!p_igetw(&tempMsgString.listpos,f,true))
4108 {
4109 return qe_invalid;
4110 }
4111 5357 }
4112 }
4113
4114
1/2
✓ Branch 0 taken 5873 times.
✗ Branch 1 not taken.
5873 if(keepdata==true)
4115 {
4116
1/2
✓ Branch 0 taken 5873 times.
✗ Branch 1 not taken.
5873 MsgStrings[i].copyAll(tempMsgString);
4117 5873 }
4118 5873 }
4119 }
4120
4121
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata==true)
4122 {
4123 99 msg_count=temp_msg_count;
4124 99 }
4125
4126 99 return 0;
4127 99 }
4128
4129 99 int32_t readdoorcombosets(PACKFILE *f, zquestheader *Header, bool keepdata)
4130 {
4131
1/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
99 if((Header->zelda_version < 0x192)||
4132
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ((Header->zelda_version == 0x192)&&(Header->build<158)))
4133 {
4134 return 0;
4135 }
4136
4137 99 word temp_door_combo_set_count=0;
4138 DoorComboSet tempDoorComboSet;
4139 word dummy_word;
4140 int32_t dummy_long;
4141 byte padding;
4142 99 int32_t s_version = 0;
4143
4144
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata==true)
4145 {
4146
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<MAXDOORCOMBOSETS; i++)
4147 {
4148 25344 memset(DoorComboSets+i, 0, sizeof(DoorComboSet));
4149 25344 }
4150 99 }
4151
4152
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(Header->zelda_version > 0x192)
4153 {
4154 //section version info
4155
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&s_version,f,true))
4156 {
4157 return qe_invalid;
4158 }
4159
4160 99 FFCore.quest_format[vDoors] = s_version;
4161
4162 //al_trace("Door combo sets version %d\n", dummy_word);
4163
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&dummy_word,f,true))
4164 {
4165 return qe_invalid;
4166 }
4167
4168 //section size
4169
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetl(&dummy_long,f,true))
4170 {
4171 return qe_invalid;
4172 }
4173 99 }
4174
4175 //finally... section data
4176
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&temp_door_combo_set_count,f,true))
4177 {
4178 return qe_invalid;
4179 }
4180
4181
2/2
✓ Branch 0 taken 727 times.
✓ Branch 1 taken 99 times.
826 for(int32_t i=0; i<temp_door_combo_set_count; i++)
4182 {
4183 727 memset(&tempDoorComboSet, 0, sizeof(DoorComboSet));
4184
4185 //name
4186
1/2
✓ Branch 0 taken 727 times.
✗ Branch 1 not taken.
727 if(!pfread(&tempDoorComboSet.name,sizeof(tempDoorComboSet.name),f,true))
4187 {
4188 return qe_invalid;
4189 }
4190
4191
1/2
✓ Branch 0 taken 727 times.
✗ Branch 1 not taken.
727 if(Header->zelda_version < 0x193)
4192 {
4193 if(!p_getc(&padding,f,true))
4194 {
4195 return qe_invalid;
4196 }
4197 }
4198
4199 //up door
4200
2/2
✓ Branch 0 taken 6543 times.
✓ Branch 1 taken 727 times.
7270 for(int32_t j=0; j<9; j++)
4201 {
4202
2/2
✓ Branch 0 taken 26172 times.
✓ Branch 1 taken 6543 times.
32715 for(int32_t k=0; k<4; k++)
4203 {
4204
1/2
✓ Branch 0 taken 26172 times.
✗ Branch 1 not taken.
26172 if(!p_igetw(&tempDoorComboSet.doorcombo_u[j][k],f,true))
4205 {
4206 return qe_invalid;
4207 }
4208 26172 }
4209 6543 }
4210
4211
2/2
✓ Branch 0 taken 6543 times.
✓ Branch 1 taken 727 times.
7270 for(int32_t j=0; j<9; j++)
4212 {
4213
2/2
✓ Branch 0 taken 26172 times.
✓ Branch 1 taken 6543 times.
32715 for(int32_t k=0; k<4; k++)
4214 {
4215
1/2
✓ Branch 0 taken 26172 times.
✗ Branch 1 not taken.
26172 if(!p_getc(&tempDoorComboSet.doorcset_u[j][k],f,true))
4216 {
4217 return qe_invalid;
4218 }
4219 26172 }
4220 6543 }
4221
4222 //down door
4223
2/2
✓ Branch 0 taken 6543 times.
✓ Branch 1 taken 727 times.
7270 for(int32_t j=0; j<9; j++)
4224 {
4225
2/2
✓ Branch 0 taken 26172 times.
✓ Branch 1 taken 6543 times.
32715 for(int32_t k=0; k<4; k++)
4226 {
4227
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26172 times.
26172 if(!p_igetw(&tempDoorComboSet.doorcombo_d[j][k],f,true))
4228 {
4229 return qe_invalid;
4230 }
4231 26172 }
4232 6543 }
4233
4234
2/2
✓ Branch 0 taken 6543 times.
✓ Branch 1 taken 727 times.
7270 for(int32_t j=0; j<9; j++)
4235 {
4236
2/2
✓ Branch 0 taken 26172 times.
✓ Branch 1 taken 6543 times.
32715 for(int32_t k=0; k<4; k++)
4237 {
4238
1/2
✓ Branch 0 taken 26172 times.
✗ Branch 1 not taken.
26172 if(!p_getc(&tempDoorComboSet.doorcset_d[j][k],f,true))
4239 {
4240 return qe_invalid;
4241 }
4242 26172 }
4243 6543 }
4244
4245 //left door
4246
2/2
✓ Branch 0 taken 6543 times.
✓ Branch 1 taken 727 times.
7270 for(int32_t j=0; j<9; j++)
4247 {
4248
2/2
✓ Branch 0 taken 39258 times.
✓ Branch 1 taken 6543 times.
45801 for(int32_t k=0; k<6; k++)
4249 {
4250
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39258 times.
39258 if(!p_igetw(&tempDoorComboSet.doorcombo_l[j][k],f,true))
4251 {
4252 return qe_invalid;
4253 }
4254 39258 }
4255 6543 }
4256
4257
2/2
✓ Branch 0 taken 6543 times.
✓ Branch 1 taken 727 times.
7270 for(int32_t j=0; j<9; j++)
4258 {
4259
2/2
✓ Branch 0 taken 39258 times.
✓ Branch 1 taken 6543 times.
45801 for(int32_t k=0; k<6; k++)
4260 {
4261
1/2
✓ Branch 0 taken 39258 times.
✗ Branch 1 not taken.
39258 if(!p_getc(&tempDoorComboSet.doorcset_l[j][k],f,true))
4262 {
4263 return qe_invalid;
4264 }
4265 39258 }
4266 6543 }
4267
4268 //right door
4269
2/2
✓ Branch 0 taken 6543 times.
✓ Branch 1 taken 727 times.
7270 for(int32_t j=0; j<9; j++)
4270 {
4271
2/2
✓ Branch 0 taken 39258 times.
✓ Branch 1 taken 6543 times.
45801 for(int32_t k=0; k<6; k++)
4272 {
4273
1/2
✓ Branch 0 taken 39258 times.
✗ Branch 1 not taken.
39258 if(!p_igetw(&tempDoorComboSet.doorcombo_r[j][k],f,true))
4274 {
4275 return qe_invalid;
4276 }
4277 39258 }
4278 6543 }
4279
4280
2/2
✓ Branch 0 taken 6543 times.
✓ Branch 1 taken 727 times.
7270 for(int32_t j=0; j<9; j++)
4281 {
4282
2/2
✓ Branch 0 taken 39258 times.
✓ Branch 1 taken 6543 times.
45801 for(int32_t k=0; k<6; k++)
4283 {
4284
1/2
✓ Branch 0 taken 39258 times.
✗ Branch 1 not taken.
39258 if(!p_getc(&tempDoorComboSet.doorcset_r[j][k],f,true))
4285 {
4286 return qe_invalid;
4287 }
4288 39258 }
4289 6543 }
4290
4291 //up bomb rubble
4292
2/2
✓ Branch 0 taken 1454 times.
✓ Branch 1 taken 727 times.
2181 for(int32_t j=0; j<2; j++)
4293 {
4294
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1454 times.
1454 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_u[j],f,true))
4295 {
4296 return qe_invalid;
4297 }
4298 1454 }
4299
4300
2/2
✓ Branch 0 taken 1454 times.
✓ Branch 1 taken 727 times.
2181 for(int32_t j=0; j<2; j++)
4301 {
4302
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1454 times.
1454 if(!p_getc(&tempDoorComboSet.bombdoorcset_u[j],f,true))
4303 {
4304 return qe_invalid;
4305 }
4306 1454 }
4307
4308 //down bomb rubble
4309
2/2
✓ Branch 0 taken 1454 times.
✓ Branch 1 taken 727 times.
2181 for(int32_t j=0; j<2; j++)
4310 {
4311
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1454 times.
1454 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_d[j],f,true))
4312 {
4313 return qe_invalid;
4314 }
4315 1454 }
4316
4317
2/2
✓ Branch 0 taken 1454 times.
✓ Branch 1 taken 727 times.
2181 for(int32_t j=0; j<2; j++)
4318 {
4319
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1454 times.
1454 if(!p_getc(&tempDoorComboSet.bombdoorcset_d[j],f,true))
4320 {
4321 return qe_invalid;
4322 }
4323 1454 }
4324
4325 //left bomb rubble
4326
2/2
✓ Branch 0 taken 2181 times.
✓ Branch 1 taken 727 times.
2908 for(int32_t j=0; j<3; j++)
4327 {
4328
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2181 times.
2181 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_l[j],f,true))
4329 {
4330 return qe_invalid;
4331 }
4332 2181 }
4333
4334
2/2
✓ Branch 0 taken 2181 times.
✓ Branch 1 taken 727 times.
2908 for(int32_t j=0; j<3; j++)
4335 {
4336
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2181 times.
2181 if(!p_getc(&tempDoorComboSet.bombdoorcset_l[j],f,true))
4337 {
4338 return qe_invalid;
4339 }
4340 2181 }
4341
4342
1/2
✓ Branch 0 taken 727 times.
✗ Branch 1 not taken.
727 if(Header->zelda_version < 0x193)
4343 {
4344 if(!p_getc(&padding,f,true))
4345 {
4346 return qe_invalid;
4347 }
4348
4349 }
4350
4351 //right bomb rubble
4352
2/2
✓ Branch 0 taken 2181 times.
✓ Branch 1 taken 727 times.
2908 for(int32_t j=0; j<3; j++)
4353 {
4354
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2181 times.
2181 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_r[j],f,true))
4355 {
4356 return qe_invalid;
4357 }
4358 2181 }
4359
4360
2/2
✓ Branch 0 taken 2181 times.
✓ Branch 1 taken 727 times.
2908 for(int32_t j=0; j<3; j++)
4361 {
4362
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2181 times.
2181 if(!p_getc(&tempDoorComboSet.bombdoorcset_r[j],f,true))
4363 {
4364 return qe_invalid;
4365 }
4366 2181 }
4367
4368
1/2
✓ Branch 0 taken 727 times.
✗ Branch 1 not taken.
727 if(Header->zelda_version < 0x193)
4369 {
4370 if(!p_getc(&padding,f,true))
4371 {
4372 return qe_invalid;
4373 }
4374 }
4375
4376 //walkthrough stuff
4377
2/2
✓ Branch 0 taken 2908 times.
✓ Branch 1 taken 727 times.
3635 for(int32_t j=0; j<4; j++)
4378 {
4379
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2908 times.
2908 if(!p_igetw(&tempDoorComboSet.walkthroughcombo[j],f,true))
4380 {
4381 return qe_invalid;
4382 }
4383 2908 }
4384
4385
2/2
✓ Branch 0 taken 2908 times.
✓ Branch 1 taken 727 times.
3635 for(int32_t j=0; j<4; j++)
4386 {
4387
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2908 times.
2908 if(!p_getc(&tempDoorComboSet.walkthroughcset[j],f,true))
4388 {
4389 return qe_invalid;
4390 }
4391 2908 }
4392
4393 //flags
4394
2/2
✓ Branch 0 taken 1454 times.
✓ Branch 1 taken 727 times.
2181 for(int32_t j=0; j<2; j++)
4395 {
4396
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1454 times.
1454 if(!p_getc(&tempDoorComboSet.flags[j],f,true))
4397 {
4398 return qe_invalid;
4399 }
4400 1454 }
4401
4402
1/2
✓ Branch 0 taken 727 times.
✗ Branch 1 not taken.
727 if(Header->zelda_version < 0x193)
4403 {
4404 if(!pfread(&tempDoorComboSet.expansion,sizeof(tempDoorComboSet.expansion),f,true))
4405 {
4406 return qe_invalid;
4407 }
4408 }
4409
4410
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 727 times.
727 if(keepdata==true)
4411 {
4412 727 memcpy(&DoorComboSets[i], &tempDoorComboSet, sizeof(tempDoorComboSet));
4413 727 }
4414 727 }
4415
4416
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata==true)
4417 {
4418 99 door_combo_set_count=temp_door_combo_set_count;
4419 99 }
4420
4421 99 return 0;
4422 99 }
4423
4424 int32_t count_dmaps()
4425 {
4426 int32_t i=MAXDMAPS-1;
4427 bool found=false;
4428
4429 while(i>=0 && !found)
4430 {
4431 if((DMaps[i].map!=0)||(DMaps[i].level!=0)||(DMaps[i].xoff!=0)||
4432 (DMaps[i].compass!=0)||(DMaps[i].color!=0)||(DMaps[i].midi!=0)||
4433 (DMaps[i].cont!=0)||(DMaps[i].type!=0))
4434 found=true;
4435
4436 for(int32_t j=0; j<8; j++)
4437 {
4438 if(DMaps[i].grid[j]!=0)
4439
4440 found=true;
4441 }
4442
4443 if((DMaps[i].name[0]!=0)||(DMaps[i].title[0]!=0)||
4444 (DMaps[i].intro[0]!=0)||(DMaps[i].tmusic[0]!=0))
4445 found=true;
4446
4447 if((DMaps[i].minimap_1_tile!=0)||(DMaps[i].minimap_2_tile!=0)||
4448 (DMaps[i].largemap_1_tile!=0)||(DMaps[i].largemap_2_tile!=0)||
4449 (DMaps[i].minimap_1_cset!=0)||(DMaps[i].minimap_2_cset!=0)||
4450 (DMaps[i].largemap_1_cset!=0)||(DMaps[i].largemap_2_cset!=0))
4451 found=true;
4452
4453 if(!found)
4454 {
4455 i--;
4456 }
4457 }
4458
4459 return i+1;
4460 }
4461
4462
4463 int32_t count_shops(miscQdata *Misc)
4464 {
4465 int32_t i=255,j;
4466 bool found=false;
4467
4468 while(i>=0 && !found)
4469 {
4470 j=2;
4471
4472 while(j>=0 && !found)
4473 {
4474 if((Misc->shop[i].hasitem[j]!=0)||(Misc->shop[i].price[j]!=0))
4475 {
4476 found=true;
4477 }
4478 else
4479 {
4480 j--;
4481 }
4482 }
4483
4484 if(Misc->shop[i].name[0]!=0)
4485 {
4486 found=true;
4487 }
4488
4489 if(!found)
4490 {
4491 i--;
4492 }
4493 }
4494
4495 return i+1;
4496 }
4497
4498 int32_t count_infos(miscQdata *Misc)
4499 {
4500 int32_t i=255,j;
4501 bool found=false;
4502
4503 while(i>=0 && !found)
4504 {
4505 j=2;
4506
4507 while(j>=0 && !found)
4508 {
4509 if((Misc->info[i].str[j]!=0)||(Misc->info[i].price[j]!=0))
4510 {
4511 found=true;
4512 }
4513 else
4514 {
4515 j--;
4516 }
4517 }
4518
4519 if(Misc->info[i].name[0]!=0)
4520 {
4521 found=true;
4522 }
4523
4524 if(!found)
4525 {
4526 i--;
4527 }
4528 }
4529
4530 return i+1;
4531 }
4532
4533 int32_t count_warprings(miscQdata *Misc)
4534 {
4535 int32_t i=15,j;
4536 bool found=false;
4537
4538 while(i>=0 && !found)
4539 {
4540 j=7;
4541
4542 while(j>=0 && !found)
4543 {
4544 if((Misc->warp[i].dmap[j]!=0)||(Misc->warp[i].scr[j]!=0))
4545 {
4546 found=true;
4547 }
4548 else
4549 {
4550 j--;
4551 }
4552 }
4553
4554 if(!found)
4555 {
4556 i--;
4557 }
4558 }
4559
4560 return i+1;
4561 }
4562
4563 int32_t count_palcycles(miscQdata *Misc)
4564 {
4565 int32_t i=255,j;
4566 bool found=false;
4567
4568 while(i>=0 && !found)
4569 {
4570 j=2;
4571
4572 while(j>=0 && !found)
4573 {
4574 if(Misc->cycles[i][j].count!=0)
4575 {
4576 found=true;
4577 }
4578 else
4579 {
4580 j--;
4581 }
4582 }
4583
4584 if(!found)
4585 {
4586 i--;
4587 }
4588 }
4589
4590 return i+1;
4591 }
4592
4593 158267 void clear_screen(mapscr *temp_scr)
4594 {
4595 158267 temp_scr->zero_memory();
4596 158267 }
4597
4598 99 int32_t readdmaps(PACKFILE *f, zquestheader *Header, word, word, word start_dmap, word max_dmaps, bool keepdata)
4599 {
4600 99 word dmapstoread=0;
4601 dmap tempDMap;
4602
4603 int32_t dummy;
4604 99 word s_version=0, s_cversion=0;
4605 byte padding;
4606
4607
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata==true)
4608 {
4609
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 99 times.
50787 for(int32_t i=0; i<max_dmaps; i++)
4610 {
4611 50688 memset(&DMaps[start_dmap+i],0,sizeof(dmap));
4612 50688 sprintf(DMaps[start_dmap+i].title," ");
4613 50688 sprintf(DMaps[start_dmap+i].intro," ");
4614 50688 DMaps[start_dmap+i].type |= dmCAVE;
4615 50688 }
4616 99 }
4617
4618
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!Header || Header->zelda_version > 0x192)
4619 {
4620 //section version info
4621
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&s_version,f,true))
4622 {
4623 return qe_invalid;
4624 }
4625
4626 99 FFCore.quest_format[vDMaps] = s_version;
4627
4628 //al_trace("DMaps version %d\n", s_version);
4629
4630
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&s_cversion,f,true))
4631 {
4632 return qe_invalid;
4633 }
4634
4635 //section size
4636
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetl(&dummy,f,true))
4637 {
4638 return qe_invalid;
4639 }
4640
4641 //finally... section data
4642
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&dmapstoread,f,true))
4643 {
4644 return qe_invalid;
4645 }
4646 99 }
4647 else
4648 {
4649 if((Header->zelda_version < 0x192)||
4650 ((Header->zelda_version == 0x192)&&(Header->build<5)))
4651 {
4652 dmapstoread=32;
4653 }
4654 else if(s_version <= 4)
4655 {
4656 dmapstoread=OLDMAXDMAPS;
4657 }
4658 else
4659 {
4660 dmapstoread=MAXDMAPS;
4661 }
4662 }
4663
4664
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 96 times.
99 dmapstoread=zc_min(dmapstoread, max_dmaps);
4665
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 96 times.
99 dmapstoread=zc_min(dmapstoread, MAXDMAPS-start_dmap);
4666
4667
2/2
✓ Branch 0 taken 49920 times.
✓ Branch 1 taken 99 times.
50019 for(int32_t i=start_dmap; i<dmapstoread+start_dmap; i++)
4668 {
4669 49920 memset(&tempDMap,0,sizeof(dmap));
4670 49920 sprintf(tempDMap.title," ");
4671 49920 sprintf(tempDMap.intro," ");
4672
4673
1/2
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
49920 if(!p_getc(&tempDMap.map,f,keepdata))
4674 {
4675 return qe_invalid;
4676 }
4677
4678
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 49152 times.
49920 if(s_version <= 4)
4679 {
4680 byte tempbyte;
4681
4682
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_getc(&tempbyte,f,keepdata))
4683 {
4684 return qe_invalid;
4685 }
4686
4687 768 tempDMap.level=(word)tempbyte;
4688 768 }
4689 else
4690 {
4691
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&tempDMap.level,f,keepdata))
4692 {
4693 return qe_invalid;
4694 }
4695 }
4696
4697
1/2
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
49920 if(!p_getc(&tempDMap.xoff,f,keepdata))
4698 {
4699 return qe_invalid;
4700 }
4701
4702
1/2
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
49920 if(!p_getc(&tempDMap.compass,f,keepdata))
4703 {
4704 return qe_invalid;
4705 }
4706
4707
2/2
✓ Branch 0 taken 49152 times.
✓ Branch 1 taken 768 times.
49920 if(s_version > 8) // February 2009
4708 {
4709
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&tempDMap.color,f,true))
4710 {
4711 return qe_invalid;
4712 }
4713 49152 }
4714 else
4715 {
4716 byte tempbyte;
4717
4718
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_getc(&tempbyte,f,true))
4719 {
4720 return qe_invalid;
4721 }
4722
4723 768 tempDMap.color = (word)tempbyte;
4724 }
4725
4726
1/2
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
49920 if(!p_getc(&tempDMap.midi,f,keepdata))
4727 {
4728 return qe_invalid;
4729 }
4730
4731
1/2
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
49920 if(!p_getc(&tempDMap.cont,f,keepdata))
4732 {
4733 return qe_invalid;
4734 }
4735
4736
1/2
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
49920 if(!p_getc(&tempDMap.type,f,keepdata))
4737 {
4738 return qe_invalid;
4739 }
4740
4741
3/4
✓ Branch 0 taken 369 times.
✓ Branch 1 taken 49551 times.
✓ Branch 2 taken 369 times.
✗ Branch 3 not taken.
50289 if((tempDMap.type & dmfTYPE) == dmOVERW &&
4742
1/2
✓ Branch 0 taken 369 times.
✗ Branch 1 not taken.
369 (!Header || Header->zelda_version >= 0x210)) // Not sure exactly when this changed
4743 369 tempDMap.xoff = 0;
4744
4745
2/2
✓ Branch 0 taken 399360 times.
✓ Branch 1 taken 49920 times.
449280 for(int32_t j=0; j<8; j++)
4746 {
4747
1/2
✓ Branch 0 taken 399360 times.
✗ Branch 1 not taken.
399360 if(!p_getc(&tempDMap.grid[j],f,keepdata))
4748 {
4749 return qe_invalid;
4750 }
4751 399360 }
4752
4753
3/8
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 49920 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 49920 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
49920 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<41))))
4754 {
4755 if(tempDMap.level>0&&tempDMap.level<10)
4756 {
4757 sprintf(tempDMap.title,"LEVEL-%d ", tempDMap.level);
4758 }
4759
4760 if(i==0 && Header->zelda_version <= 0x190)
4761 {
4762 tempDMap.cont-=tempDMap.xoff;
4763 tempDMap.compass-=tempDMap.xoff;
4764 }
4765
4766 //forgotten -DD
4767 if(tempDMap.level==0)
4768 {
4769 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4770 }
4771 }
4772 else
4773 {
4774
1/2
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
49920 if(!pfread(&tempDMap.name,sizeof(DMaps[0].name),f,true))
4775 {
4776 return qe_invalid;
4777 }
4778
4779
1/2
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
49920 if(!pfread(&tempDMap.title,sizeof(DMaps[0].title),f,true))
4780 {
4781 return qe_invalid;
4782 }
4783
4784
1/2
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
49920 if(!pfread(&tempDMap.intro,sizeof(DMaps[0].intro),f,true))
4785 {
4786 return qe_invalid;
4787 }
4788
4789
3/8
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 49920 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 49920 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
49920 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<152))))
4790 {
4791 if ((tempDMap.type & dmfTYPE) == dmOVERW) tempDMap.flags = dmfCAVES | dmf3STAIR | dmfWHIRLWIND | dmfGUYCAVES;
4792 if(keepdata==true)
4793 {
4794 memcpy(&DMaps[i], &tempDMap, sizeof(tempDMap));
4795 }
4796
4797 continue;
4798 }
4799
4800
2/4
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 49920 times.
✗ Branch 3 not taken.
49920 if(Header && (Header->zelda_version < 0x193))
4801 {
4802 if(!p_getc(&padding,f,keepdata))
4803 {
4804 return qe_invalid;
4805 }
4806 }
4807
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 38656 times.
49920 if ( s_version >= 11 )
4808 {
4809
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&tempDMap.minimap_1_tile,f,keepdata))
4810 {
4811 return qe_invalid;
4812 }
4813 11264 }
4814 else
4815 {
4816
1/2
✓ Branch 0 taken 38656 times.
✗ Branch 1 not taken.
38656 if(!p_igetw(&tempDMap.minimap_1_tile,f,keepdata))
4817 {
4818 return qe_invalid;
4819 }
4820 }
4821
4822
1/2
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
49920 if(!p_getc(&tempDMap.minimap_1_cset,f,keepdata))
4823 {
4824 return qe_invalid;
4825 }
4826
4827
2/4
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 49920 times.
✗ Branch 3 not taken.
49920 if(Header && (Header->zelda_version < 0x193))
4828 {
4829 if(!p_getc(&padding,f,keepdata))
4830 {
4831 return qe_invalid;
4832 }
4833 }
4834
4835
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 38656 times.
49920 if ( s_version >= 11 )
4836 {
4837
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&tempDMap.minimap_2_tile,f,keepdata))
4838 {
4839 return qe_invalid;
4840 }
4841 11264 }
4842 else
4843 {
4844
1/2
✓ Branch 0 taken 38656 times.
✗ Branch 1 not taken.
38656 if(!p_igetw(&tempDMap.minimap_2_tile,f,keepdata))
4845 {
4846 return qe_invalid;
4847 }
4848 }
4849
1/2
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
49920 if(!p_getc(&tempDMap.minimap_2_cset,f,keepdata))
4850 {
4851 return qe_invalid;
4852 }
4853
4854
2/4
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 49920 times.
✗ Branch 3 not taken.
49920 if(Header && (Header->zelda_version < 0x193))
4855 {
4856 if(!p_getc(&padding,f,keepdata))
4857 {
4858 return qe_invalid;
4859 }
4860 }
4861
4862
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 38656 times.
49920 if ( s_version >= 11 )
4863 {
4864
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&tempDMap.largemap_1_tile,f,keepdata))
4865 {
4866 return qe_invalid;
4867 }
4868 11264 }
4869 else
4870 {
4871
1/2
✓ Branch 0 taken 38656 times.
✗ Branch 1 not taken.
38656 if(!p_igetw(&tempDMap.largemap_1_tile,f,keepdata))
4872 {
4873 return qe_invalid;
4874 }
4875 }
4876
4877
1/2
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
49920 if(!p_getc(&tempDMap.largemap_1_cset,f,keepdata))
4878 {
4879 return qe_invalid;
4880 }
4881
4882
2/4
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 49920 times.
✗ Branch 3 not taken.
49920 if(Header && (Header->zelda_version < 0x193))
4883 {
4884
4885 if(!p_getc(&padding,f,keepdata))
4886 {
4887 return qe_invalid;
4888 }
4889 }
4890
4891
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 38656 times.
49920 if ( s_version >= 11 )
4892 {
4893
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&tempDMap.largemap_2_tile,f,keepdata))
4894 {
4895 return qe_invalid;
4896 }
4897 11264 }
4898 else
4899 {
4900
1/2
✓ Branch 0 taken 38656 times.
✗ Branch 1 not taken.
38656 if(!p_igetw(&tempDMap.largemap_2_tile,f,keepdata))
4901 {
4902 return qe_invalid;
4903 }
4904 }
4905
1/2
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
49920 if(!p_getc(&tempDMap.largemap_2_cset,f,keepdata))
4906 {
4907 return qe_invalid;
4908 }
4909
4910
1/2
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
49920 if(!pfread(&tempDMap.tmusic,sizeof(DMaps[0].tmusic),f,true))
4911 {
4912 return qe_invalid;
4913 }
4914 }
4915
4916
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 49152 times.
49920 if(s_version>1)
4917 {
4918
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_getc(&tempDMap.tmusictrack,f,keepdata))
4919 {
4920 return qe_invalid;
4921 }
4922
4923
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_getc(&tempDMap.active_subscreen,f,keepdata))
4924 {
4925 return qe_invalid;
4926 }
4927
4928
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_getc(&tempDMap.passive_subscreen,f,keepdata))
4929 {
4930 return qe_invalid;
4931 }
4932 49152 }
4933
4934
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 49152 times.
49920 if(s_version>2)
4935 {
4936 byte di[32];
4937
4938
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!pfread(&di, 32, f, true)) return qe_invalid;
4939
4940
2/2
✓ Branch 0 taken 12582912 times.
✓ Branch 1 taken 49152 times.
12632064 for(int32_t j=0; j<MAXITEMS; j++)
4941 {
4942
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12582912 times.
12582912 if(di[j/8] & (1 << (j%8))) tempDMap.disableditems[j]=1;
4943 12582912 else tempDMap.disableditems[j]=0;
4944 12582912 }
4945 49152 }
4946
4947
2/2
✓ Branch 0 taken 49152 times.
✓ Branch 1 taken 768 times.
49920 if(s_version >= 6)
4948 {
4949
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetl(&tempDMap.flags,f,keepdata))
4950 {
4951 return qe_invalid;
4952 }
4953 49152 }
4954
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 768 times.
768 else if(s_version>3)
4955 {
4956 char temp;
4957
4958 if(!p_getc(&temp,f,keepdata))
4959 {
4960 return qe_invalid;
4961 }
4962
4963 tempDMap.flags = temp;
4964 }
4965
3/8
✓ Branch 0 taken 573 times.
✓ Branch 1 taken 195 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 573 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
768 else if(tempDMap.level==0 && ((Header->zelda_version < 0x211) || ((Header->zelda_version == 0x211) && (Header->build<18))))
4966 {
4967 573 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4968 573 }
4969 else
4970 195 tempDMap.flags=0;
4971
4972
2/2
✓ Branch 0 taken 49152 times.
✓ Branch 1 taken 768 times.
49920 if(s_version<7)
4973 {
4974
3/4
✓ Branch 0 taken 573 times.
✓ Branch 1 taken 195 times.
✓ Branch 2 taken 573 times.
✗ Branch 3 not taken.
768 if(tempDMap.level==0 && get_bit(deprecated_rules,14))
4975 573 tempDMap.flags|= dmfVIEWMAP;
4976 768 }
4977
4978
2/2
✓ Branch 0 taken 49152 times.
✓ Branch 1 taken 768 times.
49920 if(s_version<8)
4979 {
4980
4/4
✓ Branch 0 taken 573 times.
✓ Branch 1 taken 195 times.
✓ Branch 2 taken 42 times.
✓ Branch 3 taken 531 times.
768 if(tempDMap.level==0 && (tempDMap.type&dmfTYPE)==dmDNGN)
4981 {
4982 531 tempDMap.type &= ~dmDNGN;
4983 531 tempDMap.type |= dmCAVE;
4984 531 }
4985
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 105 times.
237 else if((tempDMap.type&dmfTYPE)==dmCAVE)
4986 {
4987 105 tempDMap.flags |= dmfMINIMAPCOLORFIX;
4988 105 }
4989 768 }
4990
4991
3/8
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 49920 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 49920 times.
✗ Branch 7 not taken.
49920 if(Header && ((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>=41)))
4992 49920 && (Header->zelda_version < 0x193))
4993 {
4994 if(!p_getc(&padding,f,keepdata))
4995 {
4996 return qe_invalid;
4997 }
4998 }
4999
5000
2/2
✓ Branch 0 taken 38656 times.
✓ Branch 1 taken 11264 times.
49920 if(s_version >= 10)
5001 {
5002
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_getc(&tempDMap.sideview,f,keepdata))
5003 {
5004 return qe_invalid;
5005 }
5006 11264 }
5007
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 38656 times.
49920 if(s_version < 10) tempDMap.sideview = 0;
5008
5009 //Dmap Scripts
5010
2/2
✓ Branch 0 taken 38656 times.
✓ Branch 1 taken 11264 times.
49920 if(s_version >= 12)
5011 {
5012
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetw(&tempDMap.script,f,keepdata))
5013 {
5014 return qe_invalid;
5015 }
5016
2/2
✓ Branch 0 taken 90112 times.
✓ Branch 1 taken 11264 times.
101376 for ( int32_t q = 0; q < 8; q++ )
5017 {
5018
1/2
✓ Branch 0 taken 90112 times.
✗ Branch 1 not taken.
90112 if(!p_igetl(&tempDMap.initD[q],f,keepdata))
5019 {
5020 return qe_invalid;
5021 }
5022 90112 }
5023 11264 }
5024
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 38656 times.
49920 if ( s_version < 12 )
5025 {
5026 38656 tempDMap.script = 0;
5027
2/2
✓ Branch 0 taken 309248 times.
✓ Branch 1 taken 38656 times.
347904 for ( int32_t q = 0; q < 8; q++ )
5028 {
5029 309248 tempDMap.initD[q] = 0;
5030 309248 }
5031 38656 }
5032
5033
2/2
✓ Branch 0 taken 38656 times.
✓ Branch 1 taken 11264 times.
49920 if(s_version >= 13)
5034 {
5035
2/2
✓ Branch 0 taken 90112 times.
✓ Branch 1 taken 11264 times.
101376 for ( int32_t q = 0; q < 8; q++ )
5036 {
5037
2/2
✓ Branch 0 taken 5857280 times.
✓ Branch 1 taken 90112 times.
5947392 for ( int32_t w = 0; w < 65; w++ )
5038 {
5039
1/2
✓ Branch 0 taken 5857280 times.
✗ Branch 1 not taken.
5857280 if(!p_getc(&tempDMap.initD_label[q][w],f,keepdata))
5040 {
5041 return qe_invalid;
5042 }
5043 5857280 }
5044 90112 }
5045 11264 }
5046
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 38656 times.
49920 if ( s_version < 13 )
5047 {
5048 38656 tempDMap.script = 0;
5049
2/2
✓ Branch 0 taken 309248 times.
✓ Branch 1 taken 38656 times.
347904 for ( int32_t q = 0; q < 8; q++ )
5050 {
5051
2/2
✓ Branch 0 taken 20101120 times.
✓ Branch 1 taken 309248 times.
20410368 for ( int32_t w = 0; w < 65; w++ )
5052 20101120 tempDMap.initD_label[q][w] = 0;
5053 309248 }
5054 38656 }
5055
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 38656 times.
49920 if(s_version >= 14)
5056 {
5057
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetw(&tempDMap.active_sub_script,f,keepdata))
5058 {
5059 return qe_invalid;
5060 }
5061
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetw(&tempDMap.passive_sub_script,f,keepdata))
5062 {
5063 return qe_invalid;
5064 }
5065
2/2
✓ Branch 0 taken 90112 times.
✓ Branch 1 taken 11264 times.
101376 for ( int32_t q = 0; q < 8; ++q )
5066 {
5067
1/2
✓ Branch 0 taken 90112 times.
✗ Branch 1 not taken.
90112 if(!p_igetl(&tempDMap.sub_initD[q],f,keepdata))
5068 {
5069 return qe_invalid;
5070 }
5071 90112 }
5072
2/2
✓ Branch 0 taken 90112 times.
✓ Branch 1 taken 11264 times.
101376 for(int32_t q = 0; q < 8; ++q)
5073 {
5074
2/2
✓ Branch 0 taken 5857280 times.
✓ Branch 1 taken 90112 times.
5947392 for ( int32_t w = 0; w < 65; ++w )
5075 {
5076
1/2
✓ Branch 0 taken 5857280 times.
✗ Branch 1 not taken.
5857280 if(!p_getc(&tempDMap.sub_initD_label[q][w],f,keepdata))
5077 {
5078 return qe_invalid;
5079 }
5080 5857280 }
5081 90112 }
5082 11264 }
5083 else
5084 {
5085 38656 tempDMap.active_sub_script = 0;
5086 38656 tempDMap.passive_sub_script = 0;
5087
2/2
✓ Branch 0 taken 309248 times.
✓ Branch 1 taken 38656 times.
347904 for(int32_t q = 0; q < 8; ++q)
5088 {
5089 309248 tempDMap.sub_initD[q] = 0;
5090
2/2
✓ Branch 0 taken 20101120 times.
✓ Branch 1 taken 309248 times.
20410368 for(int32_t w = 0; w < 65; ++w)
5091 20101120 tempDMap.sub_initD_label[q][w] = 0;
5092 309248 }
5093 }
5094
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 38656 times.
49920 if(s_version >= 15)
5095 {
5096
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetw(&tempDMap.onmap_script,f,keepdata))
5097 {
5098 return qe_invalid;
5099 }
5100
2/2
✓ Branch 0 taken 90112 times.
✓ Branch 1 taken 11264 times.
101376 for ( int32_t q = 0; q < 8; ++q )
5101 {
5102
1/2
✓ Branch 0 taken 90112 times.
✗ Branch 1 not taken.
90112 if(!p_igetl(&tempDMap.onmap_initD[q],f,keepdata))
5103 {
5104 return qe_invalid;
5105 }
5106 90112 }
5107
2/2
✓ Branch 0 taken 90112 times.
✓ Branch 1 taken 11264 times.
101376 for(int32_t q = 0; q < 8; ++q)
5108 {
5109
2/2
✓ Branch 0 taken 5857280 times.
✓ Branch 1 taken 90112 times.
5947392 for ( int32_t w = 0; w < 65; ++w )
5110 {
5111
1/2
✓ Branch 0 taken 5857280 times.
✗ Branch 1 not taken.
5857280 if(!p_getc(&tempDMap.onmap_initD_label[q][w],f,keepdata))
5112 {
5113 return qe_invalid;
5114 }
5115 5857280 }
5116 90112 }
5117 11264 }
5118 else
5119 {
5120 38656 tempDMap.onmap_script = 0;
5121
2/2
✓ Branch 0 taken 309248 times.
✓ Branch 1 taken 38656 times.
347904 for(int32_t q = 0; q < 8; ++q)
5122 {
5123 309248 tempDMap.onmap_initD[q] = 0;
5124
2/2
✓ Branch 0 taken 20101120 times.
✓ Branch 1 taken 309248 times.
20410368 for(int32_t w = 0; w < 65; ++w)
5125 {
5126 20101120 tempDMap.onmap_initD_label[q][w] = 0;
5127 20101120 }
5128 309248 }
5129 }
5130
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 38656 times.
49920 if(s_version >= 16)
5131 {
5132
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11264 times.
11264 if(!p_igetw(&tempDMap.mirrorDMap,f,keepdata))
5133 {
5134 return qe_invalid;
5135 }
5136 11264 }
5137 else
5138 {
5139 38656 tempDMap.mirrorDMap = -1;
5140 }
5141
5142
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49920 times.
49920 if(keepdata==true)
5143 {
5144 49920 memcpy(&DMaps[i], &tempDMap, sizeof(tempDMap));
5145 49920 }
5146 49920 }
5147
5148 99 return 0;
5149 99 }
5150
5151 96 int32_t readmisccolors(PACKFILE *f, zquestheader *Header, miscQdata *Misc, bool keepdata)
5152 {
5153 //these are here to bypass compiler warnings about unused arguments
5154 96 Header=Header;
5155
5156 miscQdata temp_misc;
5157 96 word s_version=0, s_cversion=0;
5158 96 int32_t tempsize=0;
5159 word dummyw;
5160
5161 96 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5162
5163 //section version info
5164
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_igetw(&s_version,f,true))
5165 {
5166 return qe_invalid;
5167 }
5168
5169 96 FFCore.quest_format[vColours] = s_version;
5170
5171 96 al_trace("Misc Colours section version: %d\n", s_version);
5172
5173 //al_trace("Misc. colors version %d\n", s_version);
5174
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetw(&s_cversion,f,true))
5175 {
5176 return qe_invalid;
5177 }
5178
5179
5180 //section size
5181
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&tempsize,f,true))
5182 {
5183 return qe_invalid;
5184 }
5185
5186 //finally... section data
5187 96 readsize=0;
5188
5189
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.text,f,true))
5190 {
5191 return qe_invalid;
5192 }
5193
5194
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.caption,f,true))
5195 {
5196 return qe_invalid;
5197 }
5198
5199
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.overw_bg,f,true))
5200 {
5201 return qe_invalid;
5202 }
5203
5204
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.dngn_bg,f,true))
5205 {
5206 return qe_invalid;
5207 }
5208
5209
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.dngn_fg,f,true))
5210 {
5211 return qe_invalid;
5212 }
5213
5214
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.cave_fg,f,true))
5215 {
5216 return qe_invalid;
5217 }
5218
5219
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.bs_dk,f,true))
5220 {
5221 return qe_invalid;
5222 }
5223
5224
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.bs_goal,f,true))
5225 {
5226 return qe_invalid;
5227 }
5228
5229
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.compass_lt,f,true))
5230 {
5231 return qe_invalid;
5232 }
5233
5234
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.compass_dk,f,true))
5235 {
5236 return qe_invalid;
5237 }
5238
5239
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.subscr_bg,f,true))
5240 {
5241 return qe_invalid;
5242 }
5243
5244
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.triframe_color,f,true))
5245 {
5246 return qe_invalid;
5247 }
5248
5249
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.hero_dot,f,true))
5250 {
5251 return qe_invalid;
5252 }
5253
5254
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.bmap_bg,f,true))
5255 {
5256 return qe_invalid;
5257 }
5258
5259
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.bmap_fg,f,true))
5260 {
5261 return qe_invalid;
5262 }
5263
5264
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.triforce_cset,f,true))
5265 {
5266 return qe_invalid;
5267 }
5268
5269
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.triframe_cset,f,true))
5270 {
5271 return qe_invalid;
5272 }
5273
5274
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.overworld_map_cset,f,true))
5275 {
5276 return qe_invalid;
5277 }
5278
5279
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f,true))
5280 {
5281 return qe_invalid;
5282 }
5283
5284
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.blueframe_cset,f,true))
5285 {
5286 return qe_invalid;
5287 }
5288
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 74 times.
96 if(s_version < 4)
5289 {
5290
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 if(!p_igetw(&dummyw,f,true))
5291 return qe_invalid;
5292 74 temp_misc.colors.triforce_tile = dummyw;
5293
5294
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 if(!p_igetw(&dummyw,f,true))
5295 return qe_invalid;
5296 74 temp_misc.colors.triframe_tile = dummyw;
5297
5298
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 if(!p_igetw(&dummyw,f,true))
5299 return qe_invalid;
5300 74 temp_misc.colors.overworld_map_tile = dummyw;
5301
5302
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 if(!p_igetw(&dummyw,f,true))
5303 return qe_invalid;
5304 74 temp_misc.colors.dungeon_map_tile = dummyw;
5305
5306
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 if(!p_igetw(&dummyw,f,true))
5307 return qe_invalid;
5308 74 temp_misc.colors.blueframe_tile = dummyw;
5309
5310
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 if(!p_igetw(&dummyw,f,true))
5311 return qe_invalid;
5312 74 temp_misc.colors.HCpieces_tile = dummyw;
5313 74 }
5314
5315
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.HCpieces_cset,f,true))
5316 {
5317 return qe_invalid;
5318 }
5319
5320
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.subscr_shadow,f,true))
5321 {
5322 return qe_invalid;
5323 }
5324
5325
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(s_version < 2)
5326 {
5327 temp_misc.colors.msgtext = 0x01;
5328 }
5329 else
5330 {
5331
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.msgtext, f, true))
5332 {
5333 return qe_invalid;
5334 }
5335 }
5336
5337
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 22 times.
96 if ( s_version >= 3 ) //expanded tile pages to 825
5338 {
5339
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(!p_igetl(&temp_misc.colors.triforce_tile,f,true))
5340 {
5341 return qe_invalid;
5342 }
5343
5344
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(!p_igetl(&temp_misc.colors.triframe_tile,f,true))
5345 {
5346 return qe_invalid;
5347 }
5348
5349
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(!p_igetl(&temp_misc.colors.overworld_map_tile,f,true))
5350 {
5351 return qe_invalid;
5352 }
5353
5354
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(!p_igetl(&temp_misc.colors.dungeon_map_tile,f,true))
5355 {
5356 return qe_invalid;
5357 }
5358
5359
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(!p_igetl(&temp_misc.colors.blueframe_tile,f,true))
5360 {
5361 return qe_invalid;
5362 }
5363
5364
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if(!p_igetl(&temp_misc.colors.HCpieces_tile,f,true))
5365 {
5366 return qe_invalid;
5367 }
5368 22 }
5369
5370
5371
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(keepdata==true)
5372 {
5373 96 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5374 96 }
5375
5376 96 return 0;
5377 96 }
5378
5379 96 int32_t readgameicons(PACKFILE *f, zquestheader *, miscQdata *Misc, bool keepdata)
5380 {
5381 miscQdata temp_misc;
5382 96 word s_version=0, s_cversion=0;
5383 byte icons;
5384 96 int32_t tempsize=0;
5385
5386 96 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5387
5388 //section version info
5389
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_igetw(&s_version,f,true))
5390 {
5391 return qe_invalid;
5392 }
5393
5394 96 FFCore.quest_format[vIcons] = s_version;
5395
5396 //al_trace("Game icons version %d\n", s_version);
5397
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetw(&s_cversion,f,true))
5398 {
5399 return qe_invalid;
5400 }
5401
5402
5403 //section size
5404
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&tempsize,f,true))
5405 {
5406 return qe_invalid;
5407 }
5408
5409 //finally... section data
5410 96 readsize=0;
5411
5412 96 icons=4;
5413
5414
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 74 times.
96 if ( s_version >= 10 )
5415 {
5416
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t i=0; i<icons; i++)
5417 {
5418
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_igetl(&temp_misc.icons[i],f,true))
5419 {
5420 return qe_invalid;
5421 }
5422 88 }
5423 22 }
5424 else
5425 {
5426
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 74 times.
370 for(int32_t i=0; i<icons; i++)
5427 {
5428
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 296 times.
296 if(!p_igetw(&temp_misc.icons[i],f,true))
5429 {
5430 return qe_invalid;
5431 }
5432 296 }
5433 }
5434
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(keepdata==true)
5435 {
5436 96 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5437 96 }
5438
5439 96 return 0;
5440 96 }
5441
5442 99 int32_t readmisc(PACKFILE *f, zquestheader *Header, miscQdata *Misc, bool keepdata)
5443 {
5444 99 word maxinfos=256;
5445 99 word maxshops=256;
5446 99 word shops=16, infos=16, warprings=8, palcycles=256, windwarps=9, triforces=8, icons=4;
5447 99 word ponds=16, pondsize=72, expansionsize=98*2;
5448 byte tempbyte, padding;
5449 miscQdata temp_misc;
5450 99 word s_version=0, s_cversion=0;
5451 word swaptmp;
5452 99 int32_t tempsize=0;
5453
5454 99 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5455
5456
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<maxshops; ++i)
5457 {
5458 25344 memset(&temp_misc.shop, 0, sizeof(shoptype)*256);
5459 25344 }
5460
5461
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<maxinfos; ++i)
5462 {
5463 25344 memset(&temp_misc.info, 0, sizeof(infotype)*256);
5464 25344 }
5465
5466
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(Header->zelda_version > 0x192)
5467 {
5468 //section version info
5469
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&s_version,f,true))
5470 {
5471 return qe_invalid;
5472 }
5473
5474 99 FFCore.quest_format[vMisc] = s_version;
5475
5476 //al_trace("Misc. data version %d\n", s_version);
5477
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&s_cversion,f,true))
5478 {
5479 return qe_invalid;
5480 }
5481
5482
5483 //section size
5484
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetl(&tempsize,f,true))
5485 {
5486 return qe_invalid;
5487 }
5488 99 }
5489
5490 //finally... section data
5491 99 readsize=0;
5492
5493 //shops
5494
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(Header->zelda_version > 0x192)
5495 {
5496
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&shops,f,true))
5497 {
5498 return qe_invalid;
5499 }
5500 99 }
5501
5502
2/2
✓ Branch 0 taken 1002 times.
✓ Branch 1 taken 99 times.
1101 for(int32_t i=0; i<shops; i++)
5503 {
5504
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 978 times.
1002 if(s_version > 6)
5505 {
5506
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 978 times.
978 if(!pfread(temp_misc.shop[i].name,sizeof(temp_misc.shop[i].name),f,true))
5507 {
5508 return qe_invalid;
5509 }
5510 978 }
5511
5512
2/2
✓ Branch 0 taken 3006 times.
✓ Branch 1 taken 1002 times.
4008 for(int32_t j=0; j<3; j++)
5513 {
5514
1/2
✓ Branch 0 taken 3006 times.
✗ Branch 1 not taken.
3006 if(!p_getc(&temp_misc.shop[i].item[j],f,true))
5515 {
5516 return qe_invalid;
5517 }
5518
5519
2/2
✓ Branch 0 taken 2934 times.
✓ Branch 1 taken 72 times.
3006 if(s_version < 4)
5520 {
5521 72 temp_misc.shop[i].hasitem[j] = (temp_misc.shop[i].item[j] == 0) ? 0 : 1;
5522 72 }
5523 3006 }
5524
5525
1/2
✓ Branch 0 taken 1002 times.
✗ Branch 1 not taken.
1002 if(Header->zelda_version < 0x193)
5526 {
5527 if(!p_getc(&tempbyte,f,true))
5528 {
5529 return qe_invalid;
5530 }
5531 }
5532
5533
2/2
✓ Branch 0 taken 3006 times.
✓ Branch 1 taken 1002 times.
4008 for(int32_t j=0; j<3; j++)
5534 {
5535
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3006 times.
3006 if(!p_igetw(&temp_misc.shop[i].price[j],f,true))
5536 {
5537 return qe_invalid;
5538 }
5539 3006 }
5540
5541
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 978 times.
1002 if(s_version > 3)
5542 {
5543
2/2
✓ Branch 0 taken 2934 times.
✓ Branch 1 taken 978 times.
3912 for(int32_t j=0; j<3; j++)
5544 {
5545
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2934 times.
2934 if(!p_getc(&temp_misc.shop[i].hasitem[j],f,true))
5546 return qe_invalid;
5547 2934 }
5548 978 }
5549
5550 /*
5551 if(s_version < 8)
5552 {
5553 for(int32_t j=0; j<3; j++)
5554 {
5555 (&temp_misc.shop[i].str[j])=0; //initialise.
5556 }
5557 }
5558 */
5559 1002 }
5560
5561 //filter all the 0 items to the end (yeah, bubble sort; sue me)
5562
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<maxshops; ++i)
5563 {
5564
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 25344 times.
76032 for(int32_t j=0; j<3-1; j++)
5565 {
5566
2/2
✓ Branch 0 taken 76032 times.
✓ Branch 1 taken 50688 times.
126720 for(int32_t k=0; k<2-j; k++)
5567 {
5568
2/2
✓ Branch 0 taken 2146 times.
✓ Branch 1 taken 73886 times.
76032 if(temp_misc.shop[i].hasitem[k]==0)
5569 {
5570 73886 swaptmp = temp_misc.shop[i].item[k];
5571 73886 temp_misc.shop[i].item[k] = temp_misc.shop[i].item[k+1];
5572 73886 temp_misc.shop[i].item[k+1] = swaptmp;
5573 73886 swaptmp = temp_misc.shop[i].price[k];
5574 73886 temp_misc.shop[i].price[k] = temp_misc.shop[i].price[k+1];
5575 73886 temp_misc.shop[i].price[k+1] = swaptmp;
5576 73886 swaptmp = temp_misc.shop[i].hasitem[k];
5577 73886 temp_misc.shop[i].hasitem[k] = temp_misc.shop[i].hasitem[k+1];
5578 73886 temp_misc.shop[i].hasitem[k+1] = swaptmp;
5579 73886 }
5580 76032 }
5581 50688 }
5582 25344 }
5583
5584 //infos
5585
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(Header->zelda_version > 0x192)
5586 {
5587
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&infos,f,true))
5588 {
5589 return qe_invalid;
5590 }
5591 99 }
5592
5593
2/2
✓ Branch 0 taken 1433 times.
✓ Branch 1 taken 99 times.
1532 for(int32_t i=0; i<infos; i++)
5594 {
5595
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 1424 times.
1433 if(s_version > 6)
5596 {
5597
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1424 times.
1424 if(!pfread(temp_misc.info[i].name,sizeof(temp_misc.info[i].name),f,true))
5598 {
5599 return qe_invalid;
5600 }
5601 1424 }
5602
5603
2/2
✓ Branch 0 taken 4299 times.
✓ Branch 1 taken 1433 times.
5732 for(int32_t j=0; j<3; j++)
5604 {
5605
1/4
✓ Branch 0 taken 4299 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4299 if((Header->zelda_version < 0x192)||
5606
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4299 times.
4299 ((Header->zelda_version == 0x192)&&(Header->build<146)))
5607 {
5608 if(!p_getc(&tempbyte,f,true))
5609 {
5610 return qe_invalid;
5611 }
5612
5613 temp_misc.info[i].str[j]=tempbyte;
5614 }
5615 else
5616 {
5617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4299 times.
4299 if(!p_igetw(&temp_misc.info[i].str[j],f,true))
5618 {
5619 return qe_invalid;
5620 }
5621 }
5622 4299 }
5623
5624
1/2
✓ Branch 0 taken 1433 times.
✗ Branch 1 not taken.
1433 if(Header->zelda_version < 0x193)
5625 {
5626 if(!p_getc(&tempbyte,f,true))
5627 {
5628 return qe_invalid;
5629 }
5630 }
5631
5632
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1433 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1433 if((Header->zelda_version == 0x192)&&(Header->build>145))
5633 {
5634 if(!p_getc(&padding,f,true))
5635 {
5636 return qe_invalid;
5637 }
5638 }
5639
5640
2/2
✓ Branch 0 taken 4299 times.
✓ Branch 1 taken 1433 times.
5732 for(int32_t j=0; j<3; j++)
5641 {
5642
1/2
✓ Branch 0 taken 4299 times.
✗ Branch 1 not taken.
4299 if(!p_igetw(&temp_misc.info[i].price[j],f,true))
5643 {
5644 return qe_invalid;
5645 }
5646 4299 }
5647 1433 }
5648
5649 //filter all the 0 strings to the end (yeah, bubble sort; sue me)
5650
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<maxinfos; ++i)
5651 {
5652
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 25344 times.
76032 for(int32_t j=0; j<3-1; j++)
5653 {
5654
2/2
✓ Branch 0 taken 76032 times.
✓ Branch 1 taken 50688 times.
126720 for(int32_t k=0; k<2-j; k++)
5655 {
5656
2/2
✓ Branch 0 taken 1728 times.
✓ Branch 1 taken 74304 times.
76032 if(temp_misc.info[i].str[k]==0)
5657 {
5658 74304 swaptmp = temp_misc.info[i].str[k];
5659 74304 temp_misc.info[i].str[k] = temp_misc.info[i].str[k+1];
5660 74304 temp_misc.info[i].str[k+1] = swaptmp;
5661 74304 swaptmp = temp_misc.info[i].price[k];
5662 74304 temp_misc.info[i].price[k] = temp_misc.info[i].price[k+1];
5663 74304 temp_misc.info[i].price[k+1] = swaptmp;
5664 74304 }
5665 76032 }
5666 50688 }
5667 25344 }
5668
5669
5670 //warp rings
5671
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 96 times.
99 if(s_version > 5)
5672 96 warprings++;
5673
5674
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(Header->zelda_version > 0x192)
5675 {
5676
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&warprings,f,true))
5677 {
5678 return qe_invalid;
5679 }
5680 99 }
5681
5682
2/2
✓ Branch 0 taken 958 times.
✓ Branch 1 taken 99 times.
1057 for(int32_t i=0; i<warprings; i++)
5683 {
5684
2/2
✓ Branch 0 taken 8574 times.
✓ Branch 1 taken 958 times.
9532 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5685 {
5686
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 8190 times.
8574 if(s_version <= 3)
5687 {
5688
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&tempbyte,f,true))
5689 {
5690 return qe_invalid;
5691 }
5692
5693 384 temp_misc.warp[i].dmap[j]=(word)tempbyte;
5694 384 }
5695 else
5696 {
5697
1/2
✓ Branch 0 taken 8190 times.
✗ Branch 1 not taken.
8190 if(!p_igetw(&temp_misc.warp[i].dmap[j],f,true))
5698 {
5699 return qe_invalid;
5700 }
5701 }
5702 8574 }
5703
5704
2/2
✓ Branch 0 taken 8574 times.
✓ Branch 1 taken 958 times.
9532 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5705 {
5706
1/2
✓ Branch 0 taken 8574 times.
✗ Branch 1 not taken.
8574 if(!p_getc(&temp_misc.warp[i].scr[j],f,true))
5707 {
5708 return qe_invalid;
5709 }
5710 8574 }
5711
5712
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 958 times.
958 if(!p_getc(&temp_misc.warp[i].size,f,true))
5713 {
5714 return qe_invalid;
5715 }
5716
5717
1/2
✓ Branch 0 taken 958 times.
✗ Branch 1 not taken.
958 if(Header->zelda_version < 0x193)
5718 {
5719 if(!p_getc(&tempbyte,f,true))
5720 {
5721 return qe_invalid;
5722 }
5723 }
5724 958 }
5725
5726 //palette cycles
5727
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(Header->zelda_version < 0x193) //in 1.93+, palette cycling is saved with the palettes
5728 {
5729 for(int32_t i=0; i<256; i++)
5730 {
5731 for(int32_t j=0; j<3; j++)
5732 {
5733 temp_misc.cycles[i][j].first=0;
5734 temp_misc.cycles[i][j].count=0;
5735 temp_misc.cycles[i][j].speed=0;
5736 }
5737 }
5738
5739 if((Header->zelda_version < 0x192)||
5740 ((Header->zelda_version == 0x192)&&(Header->build<73)))
5741 {
5742 palcycles=16;
5743 }
5744
5745 for(int32_t i=0; i<palcycles; i++)
5746 {
5747 for(int32_t j=0; j<3; j++)
5748 {
5749 if(!p_getc(&temp_misc.cycles[i][j].first,f,true))
5750 {
5751 return qe_invalid;
5752 }
5753
5754 if(!p_getc(&temp_misc.cycles[i][j].count,f,true))
5755 {
5756 return qe_invalid;
5757 }
5758
5759 if(!p_getc(&temp_misc.cycles[i][j].speed,f,true))
5760 {
5761 return qe_invalid;
5762 }
5763 }
5764 }
5765 }
5766
5767 //Wind warps are now just another warp ring.
5768
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version <= 5)
5769 {
5770
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(Header->zelda_version > 0x192)
5771 {
5772
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_igetw(&windwarps,f,true))
5773 {
5774 return qe_invalid;
5775 }
5776 3 }
5777
5778
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 3 times.
30 for(int32_t i=0; i<windwarps; i++)
5779 {
5780
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(s_version <= 3)
5781 {
5782
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_getc(&tempbyte,f,true))
5783 {
5784 return qe_invalid;
5785 }
5786
5787 27 temp_misc.warp[8].dmap[i]=tempbyte;
5788 27 }
5789 else
5790 {
5791 if(!p_igetw(&temp_misc.warp[8].dmap[i],f,true))
5792 {
5793 return qe_invalid;
5794 }
5795 }
5796
5797
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
27 if(!p_getc(&temp_misc.warp[8].scr[i],f,true))
5798 {
5799 return qe_invalid;
5800 }
5801
5802 27 temp_misc.warp[8].size = 9;
5803
5804
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(s_version == 5)
5805 {
5806 if(!p_getc(&tempbyte,f,true))
5807 {
5808 return qe_invalid;
5809 }
5810 }
5811 27 }
5812 3 }
5813
5814
5815 //triforce pieces
5816
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 99 times.
891 for(int32_t i=0; i<triforces; i++)
5817 {
5818
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&temp_misc.triforce[i],f,true))
5819 {
5820 return qe_invalid;
5821 }
5822 792 }
5823
5824 //misc color data
5825
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version<3)
5826 {
5827
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&temp_misc.colors.text,f,true))
5828 {
5829 return qe_invalid;
5830 }
5831
5832
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&temp_misc.colors.caption,f,true))
5833 {
5834 return qe_invalid;
5835 }
5836
5837
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&temp_misc.colors.overw_bg,f,true))
5838 {
5839 return qe_invalid;
5840 }
5841
5842
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&temp_misc.colors.dngn_bg,f,true))
5843 {
5844 return qe_invalid;
5845 }
5846
5847
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&temp_misc.colors.dngn_fg,f,true))
5848 {
5849 return qe_invalid;
5850 }
5851
5852
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&temp_misc.colors.cave_fg,f,true))
5853 {
5854 return qe_invalid;
5855 }
5856
5857
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&temp_misc.colors.bs_dk,f,true))
5858 {
5859 return qe_invalid;
5860 }
5861
5862
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&temp_misc.colors.bs_goal,f,true))
5863 {
5864 return qe_invalid;
5865 }
5866
5867
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&temp_misc.colors.compass_lt,f,true))
5868 {
5869 return qe_invalid;
5870 }
5871
5872
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&temp_misc.colors.compass_dk,f,true))
5873 {
5874 return qe_invalid;
5875 }
5876
5877
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&temp_misc.colors.subscr_bg,f,true))
5878 {
5879 return qe_invalid;
5880 }
5881
5882
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&temp_misc.colors.triframe_color,f,true))
5883 {
5884 return qe_invalid;
5885 }
5886
5887
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&temp_misc.colors.hero_dot,f,true))
5888 {
5889 return qe_invalid;
5890 }
5891
5892
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&temp_misc.colors.bmap_bg,f,true))
5893 {
5894 return qe_invalid;
5895 }
5896
5897
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&temp_misc.colors.bmap_fg,f,true))
5898 {
5899 return qe_invalid;
5900 }
5901
5902
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&temp_misc.colors.triforce_cset,f,true))
5903 {
5904 return qe_invalid;
5905 }
5906
5907
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&temp_misc.colors.triframe_cset,f,true))
5908 {
5909 return qe_invalid;
5910 }
5911
5912
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&temp_misc.colors.overworld_map_cset,f,true))
5913 {
5914 return qe_invalid;
5915 }
5916
5917
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f,true))
5918 {
5919 return qe_invalid;
5920 }
5921
5922
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&temp_misc.colors.blueframe_cset,f,true))
5923 {
5924 return qe_invalid;
5925 }
5926
5927
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_igetw(&temp_misc.colors.triforce_tile,f,true))
5928 {
5929 return qe_invalid;
5930 }
5931
5932
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_igetw(&temp_misc.colors.triframe_tile,f,true))
5933 {
5934 return qe_invalid;
5935 }
5936
5937
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_igetw(&temp_misc.colors.overworld_map_tile,f,true))
5938 {
5939 return qe_invalid;
5940 }
5941
5942
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_igetw(&temp_misc.colors.dungeon_map_tile,f,true))
5943 {
5944 return qe_invalid;
5945 }
5946
5947
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_igetw(&temp_misc.colors.blueframe_tile,f,true))
5948 {
5949 return qe_invalid;
5950 }
5951
5952
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_igetw(&temp_misc.colors.HCpieces_tile,f,true))
5953 {
5954 return qe_invalid;
5955 }
5956
5957
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&temp_misc.colors.HCpieces_cset,f,true))
5958 {
5959 return qe_invalid;
5960 }
5961
5962 3 temp_misc.colors.msgtext = 0x01;
5963
5964
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(Header->zelda_version < 0x193)
5965 {
5966 for(int32_t i=0; i<7; i++)
5967 {
5968 if(!p_getc(&tempbyte,f,true))
5969 {
5970 return qe_invalid;
5971 }
5972 }
5973 }
5974
5975
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if((Header->zelda_version == 0x192)&&(Header->build>145))
5976 {
5977 for(int32_t i=0; i<256; i++)
5978 {
5979 if(!p_getc(&tempbyte,f,true))
5980 {
5981 return qe_invalid;
5982 }
5983 }
5984 }
5985
5986
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(s_version>1)
5987 {
5988 if(!p_getc(&temp_misc.colors.subscr_shadow,f,true))
5989 {
5990 return qe_invalid;
5991 }
5992 }
5993
5994 //save game icons
5995
1/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if((Header->zelda_version < 0x192)||
5996
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 ((Header->zelda_version == 0x192)&&(Header->build<73)))
5997 {
5998 icons=3;
5999 }
6000
6001
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t i=0; i<icons; i++)
6002 {
6003
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetw(&temp_misc.icons[i],f,true))
6004 {
6005 return qe_invalid;
6006 }
6007 12 }
6008 3 }
6009
6010
1/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
99 if((Header->zelda_version < 0x192)||
6011
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ((Header->zelda_version == 0x192)&&(Header->build<30)))
6012 {
6013 if(keepdata==true)
6014 {
6015 memcpy(Misc, &temp_misc, sizeof(temp_misc));
6016 }
6017
6018 return 0;
6019 }
6020
6021 //pond information
6022
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(Header->zelda_version < 0x193)
6023 {
6024 if((Header->zelda_version == 0x192)&&(Header->build<146))
6025 {
6026 pondsize=25;
6027 }
6028
6029 for(int32_t i=0; i<ponds; i++)
6030 {
6031 for(int32_t j=0; j<pondsize; j++)
6032 {
6033 if(!p_getc(&tempbyte,f,true))
6034 {
6035 return qe_invalid;
6036
6037 }
6038 }
6039 }
6040 }
6041
6042 //end string
6043
1/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
99 if((Header->zelda_version < 0x192)||
6044
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ((Header->zelda_version == 0x192)&&(Header->build<146)))
6045 {
6046 if(!p_getc(&tempbyte,f,true))
6047 {
6048 return qe_invalid;
6049 }
6050
6051 temp_misc.endstring=tempbyte;
6052
6053 if(!p_getc(&tempbyte,f,true))
6054 {
6055 return qe_invalid;
6056 }
6057 }
6058 else
6059 {
6060
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&temp_misc.endstring,f,true))
6061 {
6062 return qe_invalid;
6063 }
6064 }
6065
6066 //expansion
6067
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(Header->zelda_version < 0x193)
6068 {
6069 if((Header->zelda_version == 0x192)&&(Header->build<73))
6070 {
6071 expansionsize=99*2;
6072 }
6073
6074 for(int32_t i=0; i<expansionsize; i++)
6075 {
6076 if(!p_getc(&tempbyte,f,true))
6077 {
6078 return qe_invalid;
6079 }
6080 }
6081 }
6082 //shops v8
6083
6084
6085
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 22 times.
99 if(s_version >= 8)
6086 {
6087
2/2
✓ Branch 0 taken 320 times.
✓ Branch 1 taken 22 times.
342 for(int32_t i=0; i<shops; i++)
6088 {
6089
2/2
✓ Branch 0 taken 960 times.
✓ Branch 1 taken 320 times.
1280 for(int32_t j=0; j<3; j++)
6090 {
6091
1/2
✓ Branch 0 taken 960 times.
✗ Branch 1 not taken.
960 if(!p_igetw(&temp_misc.shop[i].str[j],f,true))
6092 return qe_invalid;
6093 960 }
6094 320 }
6095 22 }
6096
6097 99 memset(&temp_misc.questmisc, 0, sizeof(int32_t)*32);
6098 99 memset(&temp_misc.questmisc_strings, 0, sizeof(char)*4096);
6099 99 memset(&temp_misc.zscript_last_compiled_version, 0, sizeof(int32_t));
6100
6101 //v9 includes quest misc[32]
6102
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 22 times.
99 if(s_version >= 9)
6103 {
6104
2/2
✓ Branch 0 taken 704 times.
✓ Branch 1 taken 22 times.
726 for ( int32_t q = 0; q < 32; q++ )
6105 {
6106
1/2
✓ Branch 0 taken 704 times.
✗ Branch 1 not taken.
704 if(!p_igetl(&temp_misc.questmisc[q],f,true))
6107 return qe_invalid;
6108 704 }
6109
2/2
✓ Branch 0 taken 704 times.
✓ Branch 1 taken 22 times.
726 for ( int32_t q = 0; q < 32; q++ )
6110 {
6111
2/2
✓ Branch 0 taken 90112 times.
✓ Branch 1 taken 704 times.
90816 for ( int32_t j = 0; j < 128; j++ )
6112
1/2
✓ Branch 0 taken 90112 times.
✗ Branch 1 not taken.
90112 if(!p_getc(&temp_misc.questmisc_strings[q][j],f,true))
6113 return qe_invalid;
6114 704 }
6115 22 }
6116
6117
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(s_version >= 11 )
6118 {
6119
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(!p_igetl(&temp_misc.zscript_last_compiled_version,f,true))
6120 return qe_invalid;
6121 22 }
6122
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 else if(s_version < 11 )
6123 {
6124 77 temp_misc.zscript_last_compiled_version = -1;
6125 77 }
6126
6127 99 FFCore.quest_format[vLastCompile] = temp_misc.zscript_last_compiled_version;
6128
6129
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(s_version >= 12)
6130 {
6131 byte spr;
6132
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 22 times.
5654 for(int32_t q = 0; q < sprMAX; ++q)
6133 {
6134
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_getc(&spr,f,true))
6135 return qe_invalid;
6136 5632 temp_misc.sprites[q] = spr;
6137 5632 }
6138 22 }
6139 else
6140 {
6141 77 memset(&(temp_misc.sprites), 0, sizeof(temp_misc.sprites));
6142 //temp_misc.sprites[sprFALL] = ;
6143 }
6144
6145
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(s_version >= 13)
6146 {
6147
2/2
✓ Branch 0 taken 1408 times.
✓ Branch 1 taken 22 times.
1430 for(size_t q = 0; q < 64; ++q)
6148 {
6149 1408 bottletype* bt = &(temp_misc.bottle_types[q]);
6150
1/2
✓ Branch 0 taken 1408 times.
✗ Branch 1 not taken.
1408 if (!pfread(bt->name, 32, f, true))
6151 return qe_invalid;
6152
2/2
✓ Branch 0 taken 4224 times.
✓ Branch 1 taken 1408 times.
5632 for(size_t j = 0; j < 3; ++j)
6153 {
6154
1/2
✓ Branch 0 taken 4224 times.
✗ Branch 1 not taken.
4224 if (!p_getc(&(bt->counter[j]), f, true))
6155 return qe_invalid;
6156
1/2
✓ Branch 0 taken 4224 times.
✗ Branch 1 not taken.
4224 if (!p_igetw(&(bt->amount[j]), f, true))
6157 return qe_invalid;
6158 4224 }
6159
1/2
✓ Branch 0 taken 1408 times.
✗ Branch 1 not taken.
1408 if (!p_getc(&(bt->flags), f, true))
6160 return qe_invalid;
6161
1/2
✓ Branch 0 taken 1408 times.
✗ Branch 1 not taken.
1408 if (!p_getc(&(bt->next_type), f, true))
6162 return qe_invalid;
6163 1408 }
6164
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 22 times.
5654 for(size_t q = 0; q < 256; ++q)
6165 {
6166 5632 bottleshoptype* bst = &(temp_misc.bottle_shop_types[q]);
6167
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if (!pfread(bst->name, 32, f, true))
6168 return qe_invalid;
6169
2/2
✓ Branch 0 taken 16896 times.
✓ Branch 1 taken 5632 times.
22528 for(size_t j = 0; j < 3; ++j)
6170 {
6171
1/2
✓ Branch 0 taken 16896 times.
✗ Branch 1 not taken.
16896 if (!p_getc(&(bst->fill[j]), f, true))
6172 return qe_invalid;
6173
1/2
✓ Branch 0 taken 16896 times.
✗ Branch 1 not taken.
16896 if (!p_igetw(&(bst->comb[j]), f, true))
6174 return qe_invalid;
6175
1/2
✓ Branch 0 taken 16896 times.
✗ Branch 1 not taken.
16896 if (!p_getc(&(bst->cset[j]), f, true))
6176 return qe_invalid;
6177
1/2
✓ Branch 0 taken 16896 times.
✗ Branch 1 not taken.
16896 if (!p_igetw(&(bst->price[j]), f, true))
6178 return qe_invalid;
6179
1/2
✓ Branch 0 taken 16896 times.
✗ Branch 1 not taken.
16896 if (!p_igetw(&(bst->str[j]), f, true))
6180 return qe_invalid;
6181 16896 }
6182 5632 }
6183 22 }
6184 else
6185 {
6186
2/2
✓ Branch 0 taken 4928 times.
✓ Branch 1 taken 77 times.
5005 for(size_t q = 0; q < 64; ++q)
6187 4928 temp_misc.bottle_types[q].clear();
6188
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 77 times.
19789 for(size_t q = 0; q < 256; ++q)
6189 19712 temp_misc.bottle_shop_types[q].clear();
6190 }
6191
6192
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(s_version >= 14)
6193 {
6194 byte msfx;
6195
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 22 times.
5654 for(int32_t q = 0; q < sfxMAX; ++q)
6196 {
6197
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_getc(&msfx,f,true))
6198 return qe_invalid;
6199 5632 temp_misc.miscsfx[q] = msfx;
6200 5632 }
6201 22 }
6202 else
6203 {
6204 77 memset(&(temp_misc.miscsfx), 0, sizeof(temp_misc.miscsfx));
6205 77 temp_misc.miscsfx[sfxBUSHGRASS] = WAV_ZN1GRASSCUT;
6206 77 temp_misc.miscsfx[sfxLOWHEART] = WAV_ER;
6207 }
6208
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(s_version < 15)
6209 {
6210 77 temp_misc.miscsfx[sfxHURTPLAYER] = WAV_OUCH;
6211 77 temp_misc.miscsfx[sfxHAMMERPOUND] = WAV_ZN1HAMMERPOST;
6212 77 temp_misc.miscsfx[sfxSUBSCR_ITEM_ASSIGN] = WAV_PLACE;
6213 77 temp_misc.miscsfx[sfxSUBSCR_CURSOR_MOVE] = WAV_CHIME;
6214 77 temp_misc.miscsfx[sfxREFILL] = WAV_MSG;
6215 77 temp_misc.miscsfx[sfxDRAIN] = WAV_MSG;
6216 77 }
6217
6218
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata==true)
6219 {
6220 99 memcpy(Misc, &temp_misc, sizeof(temp_misc));
6221 99 }
6222
6223 99 return 0;
6224 99 }
6225
6226 extern char *item_string[ITEMCNT];
6227 extern const char *old_item_string[iLast];
6228 extern char *weapon_string[WPNCNT];
6229 extern const char *old_weapon_string[wLast];
6230
6231 99 int32_t readitems(PACKFILE *f, word version, word build, bool keepdata, bool zgpmode)
6232 {
6233 byte padding;
6234 int32_t dummy;
6235 99 word items_to_read=MAXITEMS;
6236 itemdata tempitem;
6237 99 word s_version=0, s_cversion=0;
6238 word dummy_word;
6239
6240
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(version < 0x186)
6241 {
6242 items_to_read=64;
6243 }
6244
6245
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(version > 0x192)
6246 {
6247 99 items_to_read=0;
6248
6249 //section version info
6250
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&s_version,f,true))
6251 {
6252 return qe_invalid;
6253 }
6254
6255 99 FFCore.quest_format[vItems] = s_version;
6256
6257 //al_trace("Items version %d\n", s_version);
6258
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&s_cversion,f,true))
6259 {
6260 return qe_invalid;
6261 }
6262
6263 //section size
6264
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetl(&dummy,f,true))
6265 {
6266 return qe_invalid;
6267 }
6268
6269 //finally... section data
6270
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&items_to_read,f,true))
6271 {
6272 return qe_invalid;
6273 }
6274 99 }
6275
6276
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version>1)
6277 {
6278
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 96 times.
24672 for(int32_t i=0; i<items_to_read; i++)
6279 {
6280 char tempname[64];
6281
6282
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!pfread(tempname, 64, f, keepdata))
6283 {
6284 return qe_invalid;
6285 }
6286
6287
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24576 times.
24576 if(keepdata)
6288 {
6289 24576 strcpy(item_string[i], tempname);
6290 24576 }
6291 24576 }
6292 96 }
6293 else
6294 {
6295
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(keepdata)
6296 {
6297
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 3 times.
771 for(int32_t i=0; i<ITEMCNT; i++)
6298 {
6299 768 reset_itemname(i);
6300 768 }
6301 3 }
6302 }
6303
6304
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata)
6305 {
6306
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<MAXITEMS; i++)
6307 {
6308 25344 itemdata& id = itemsbuf[i];
6309 25344 memset(&id, 0, sizeof(itemdata));
6310 25344 id.count=-1;
6311 25344 id.playsound=WAV_SCALE;
6312 25344 reset_itembuf(&id,i);
6313 25344 }
6314 99 }
6315
6316
2/2
✓ Branch 0 taken 24786 times.
✓ Branch 1 taken 99 times.
24885 for(int32_t i=0; i<items_to_read; i++)
6317 {
6318 24786 memset(&tempitem, 0, sizeof(itemdata));
6319 24786 reset_itembuf(&tempitem,i);
6320
6321
6322
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 19154 times.
24786 if ( s_version > 35 ) //expanded tiles
6323 {
6324
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.tile,f,true))
6325 {
6326 return qe_invalid;
6327 }
6328 5632 }
6329 else
6330 {
6331
1/2
✓ Branch 0 taken 19154 times.
✗ Branch 1 not taken.
19154 if(!p_igetw(&tempitem.tile,f,true))
6332 {
6333 return qe_invalid;
6334 }
6335 }
6336
6337
1/2
✓ Branch 0 taken 24786 times.
✗ Branch 1 not taken.
24786 if(!p_getc(&tempitem.misc_flags,f,true))
6338 {
6339 return qe_invalid;
6340 }
6341
6342
1/2
✓ Branch 0 taken 24786 times.
✗ Branch 1 not taken.
24786 if(!p_getc(&tempitem.csets,f,true))
6343 {
6344 return qe_invalid;
6345 }
6346
6347
1/2
✓ Branch 0 taken 24786 times.
✗ Branch 1 not taken.
24786 if(!p_getc(&tempitem.frames,f,true))
6348 {
6349 return qe_invalid;
6350 }
6351
6352
1/2
✓ Branch 0 taken 24786 times.
✗ Branch 1 not taken.
24786 if(!p_getc(&tempitem.speed,f,true))
6353 {
6354 return qe_invalid;
6355 }
6356
6357
1/2
✓ Branch 0 taken 24786 times.
✗ Branch 1 not taken.
24786 if(!p_getc(&tempitem.delay,f,true))
6358 {
6359 return qe_invalid;
6360 }
6361
6362
1/2
✓ Branch 0 taken 24786 times.
✗ Branch 1 not taken.
24786 if(version < 0x193)
6363 {
6364 if(!p_getc(&padding,f,true))
6365 {
6366 return qe_invalid;
6367 }
6368
6369 if((version < 0x192)||((version == 0x192)&&(build<186)))
6370 {
6371 switch(i)
6372 {
6373 case iShield:
6374 tempitem.ltm=get_bit(quest_rules,qr_BSZELDA)?-12:10;
6375 break;
6376
6377 case iMShield:
6378 tempitem.ltm=get_bit(quest_rules,qr_BSZELDA)?-6:-10;
6379 break;
6380
6381 default:
6382 tempitem.ltm=0;
6383 break;
6384 }
6385
6386 tempitem.count=-1;
6387 tempitem.flags=tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=
6388 tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
6389 tempitem.family=0xFF;
6390 tempitem.playsound=WAV_SCALE;
6391 reset_itembuf(&tempitem,i);
6392
6393 if(keepdata==true)
6394 {
6395 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
6396 }
6397
6398 continue;
6399 }
6400 }
6401
6402
1/2
✓ Branch 0 taken 24786 times.
✗ Branch 1 not taken.
24786 if(!p_igetl(&tempitem.ltm,f,true))
6403 {
6404 return qe_invalid;
6405 }
6406
6407
1/2
✓ Branch 0 taken 24786 times.
✗ Branch 1 not taken.
24786 if(version < 0x193)
6408 {
6409 for(int32_t q=0; q<12; q++)
6410 {
6411 if(!p_getc(&padding,f,true))
6412 {
6413 return qe_invalid;
6414 }
6415 }
6416 }
6417
6418
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 210 times.
24786 if(s_version>1)
6419 {
6420
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 18944 times.
24576 if ( s_version >= 31 )
6421 {
6422
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.family,f,true))
6423 {
6424 return qe_invalid;
6425 }
6426 5632 }
6427 else
6428 {
6429
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_getc(&tempitem.family,f,true))
6430 {
6431 return qe_invalid;
6432 }
6433 }
6434
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(s_version < 16)
6435 if(tempitem.family == 0xFF)
6436 tempitem.family = itype_misc;
6437
6438
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_getc(&tempitem.fam_type,f,true))
6439 {
6440 return qe_invalid;
6441 }
6442
6443
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(s_version>5)
6444 {
6445
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 18944 times.
24576 if(s_version>=31)
6446 {
6447
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.power,f,true))
6448 {
6449 return qe_invalid;
6450 }
6451 5632 }
6452 else
6453 {
6454
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_getc(&tempitem.power,f,true))
6455 {
6456 return qe_invalid;
6457 }
6458 }
6459
6460 //converted flags from 16b to 32b -Z
6461
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 5632 times.
24576 if ( s_version < 41 )
6462 {
6463
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetw(&tempitem.flags,f,true))
6464 {
6465 return qe_invalid;
6466 }
6467 18944 }
6468 else
6469 {
6470
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.flags,f,true))
6471 {
6472 return qe_invalid;
6473 }
6474 }
6475 24576 }
6476 else
6477 {
6478 //tempitem.power = tempitem.fam_type;
6479 char tempchar;
6480
6481 if(!p_getc(&tempchar,f,true))
6482 {
6483 return qe_invalid;
6484 }
6485
6486 tempitem.flags |= (tempchar ? ITEM_GAMEDATA : 0);
6487 }
6488
6489
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_igetw(&tempitem.script,f,true))
6490 {
6491 return qe_invalid;
6492 }
6493
6494
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(s_version<=3)
6495 {
6496 if(tempitem.script > NUMSCRIPTITEM)
6497 {
6498 tempitem.script = 0;
6499 }
6500 }
6501
6502
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_getc(&tempitem.count,f,true))
6503 {
6504 return qe_invalid;
6505 }
6506
6507
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_igetw(&tempitem.amount,f,true))
6508 {
6509 return qe_invalid;
6510 }
6511
6512
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_igetw(&tempitem.collect_script,f,true))
6513 {
6514 return qe_invalid;
6515 }
6516
6517
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(s_version<=3)
6518 {
6519 if(tempitem.collect_script > NUMSCRIPTITEM)
6520 {
6521 tempitem.collect_script = 0;
6522 }
6523 }
6524
6525
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_igetw(&tempitem.setmax,f,true))
6526 {
6527 return qe_invalid;
6528 }
6529
6530
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_igetw(&tempitem.max,f,true))
6531 {
6532 return qe_invalid;
6533 }
6534
6535
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_getc(&tempitem.playsound,f,true))
6536 {
6537 return qe_invalid;
6538 }
6539
6540
2/2
✓ Branch 0 taken 196608 times.
✓ Branch 1 taken 24576 times.
221184 for(int32_t j=0; j<8; j++)
6541 {
6542
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_igetl(&tempitem.initiald[j],f,true))
6543 {
6544 return qe_invalid;
6545 }
6546 196608 }
6547
6548
2/2
✓ Branch 0 taken 49152 times.
✓ Branch 1 taken 24576 times.
73728 for(int32_t j=0; j<2; j++)
6549 {
6550
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_getc(&tempitem.initiala[j],f,true))
6551 {
6552 return qe_invalid;
6553 }
6554 49152 }
6555
6556
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24576 times.
24576 if(s_version>4)
6557 {
6558
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(s_version>5)
6559 {
6560
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_getc(&tempitem.wpn,f,true))
6561 {
6562 return qe_invalid;
6563 }
6564
6565
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_getc(&tempitem.wpn2,f,true))
6566 {
6567 return qe_invalid;
6568 }
6569
6570
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_getc(&tempitem.wpn3,f,true))
6571 {
6572 return qe_invalid;
6573 }
6574
6575
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_getc(&tempitem.wpn4,f,true))
6576 {
6577 return qe_invalid;
6578 }
6579
6580
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24576 times.
24576 if(s_version>=15)
6581 {
6582
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_getc(&tempitem.wpn5,f,true))
6583 {
6584 return qe_invalid;
6585 }
6586
6587
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_getc(&tempitem.wpn6,f,true))
6588 {
6589 return qe_invalid;
6590 }
6591
6592
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_getc(&tempitem.wpn7,f,true))
6593 {
6594 return qe_invalid;
6595 }
6596
6597
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_getc(&tempitem.wpn8,f,true))
6598 {
6599 return qe_invalid;
6600 }
6601
6602
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_getc(&tempitem.wpn9,f,true))
6603 {
6604 return qe_invalid;
6605 }
6606
6607
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_getc(&tempitem.wpn10,f,true))
6608 {
6609 return qe_invalid;
6610 }
6611 24576 }
6612
6613
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_getc(&tempitem.pickup_hearts,f,true))
6614 {
6615 return qe_invalid;
6616 }
6617
6618
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24576 times.
24576 if(s_version<15)
6619 {
6620 if(!p_igetw(&dummy_word,f,true))
6621 {
6622 return qe_invalid;
6623 }
6624
6625 tempitem.misc1=dummy_word;
6626
6627 if(!p_igetw(&dummy_word,f,true))
6628 {
6629 return qe_invalid;
6630 }
6631
6632 tempitem.misc2=dummy_word;
6633 }
6634 else
6635 {
6636
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_igetl(&tempitem.misc1,f,true))
6637 {
6638 return qe_invalid;
6639 }
6640
6641
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_igetl(&tempitem.misc2,f,true))
6642 {
6643 return qe_invalid;
6644 }
6645
6646 // Version 24: shICE -> shSCRIPT; previously, all shields could block script weapons
6647
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(s_version<24)
6648 {
6649 if(tempitem.family==itype_shield)
6650 {
6651 tempitem.misc1|=shSCRIPT;
6652 }
6653 }
6654 }
6655
6656
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 5632 times.
24576 if(s_version < 53)
6657 {
6658 byte tempbyte;
6659
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_getc(&tempbyte,f,true))
6660 {
6661 return qe_invalid;
6662 }
6663 18944 tempitem.cost_amount[0] = tempbyte;
6664 18944 }
6665 else
6666 {
6667
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 5632 times.
16896 for(auto q = 0; q < 2; ++q)
6668 {
6669
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetw(&tempitem.cost_amount[q],f,true))
6670 {
6671 return qe_invalid;
6672 }
6673 11264 }
6674 }
6675 24576 }
6676 else
6677 {
6678 char tempchar;
6679
6680 if(!p_getc(&tempchar,f,true))
6681 {
6682 return qe_invalid;
6683 }
6684
6685 tempitem.flags |= (tempchar ? ITEM_EDIBLE : 0);
6686 }
6687
6688 // June 2007: more misc. attributes
6689
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24576 times.
24576 if(s_version>=12)
6690 {
6691
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24576 times.
24576 if(s_version<15)
6692 {
6693 if(!p_igetw(&dummy_word,f,true))
6694 {
6695 return qe_invalid;
6696 }
6697
6698 tempitem.misc3=dummy_word;
6699
6700 if(!p_igetw(&dummy_word,f,true))
6701 {
6702 return qe_invalid;
6703 }
6704
6705 tempitem.misc4=dummy_word;
6706 }
6707 else
6708 {
6709
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_igetl(&tempitem.misc3,f,true))
6710 {
6711 return qe_invalid;
6712 }
6713
6714
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_igetl(&tempitem.misc4,f,true))
6715 {
6716 return qe_invalid;
6717 }
6718
6719
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_igetl(&tempitem.misc5,f,true))
6720 {
6721 return qe_invalid;
6722 }
6723
6724
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_igetl(&tempitem.misc6,f,true))
6725 {
6726 return qe_invalid;
6727 }
6728
6729
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_igetl(&tempitem.misc7,f,true))
6730 {
6731 return qe_invalid;
6732 }
6733
6734
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_igetl(&tempitem.misc8,f,true))
6735 {
6736 return qe_invalid;
6737 }
6738
6739
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_igetl(&tempitem.misc9,f,true))
6740 {
6741 return qe_invalid;
6742 }
6743
6744
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_igetl(&tempitem.misc10,f,true))
6745 {
6746 return qe_invalid;
6747 }
6748 }
6749
6750
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_getc(&tempitem.usesound,f,true))
6751 {
6752 return qe_invalid;
6753 }
6754
6755
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 18944 times.
24576 if(s_version >= 49)
6756 {
6757
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_getc(&tempitem.usesound2,f,true))
6758 {
6759 return qe_invalid;
6760 }
6761 5632 }
6762 18944 else tempitem.usesound2 = 0;
6763
6764
3/4
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 5632 times.
✓ Branch 2 taken 18944 times.
✗ Branch 3 not taken.
24576 if(s_version < 50 && tempitem.family == itype_mirror)
6765 {
6766 //Split continue/dmap warp effect/sfx, port for old
6767 tempitem.misc2 = tempitem.misc1;
6768 tempitem.usesound2 = tempitem.usesound;
6769 }
6770 24576 }
6771 24576 }
6772
6773
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 5632 times.
24576 if ( s_version >= 26 ) //! New itemdata vars for weapon editor. -Z
6774 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6775
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_getc(&tempitem.useweapon,f,true))
6776 {
6777 return qe_invalid;
6778 }
6779
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_getc(&tempitem.usedefence,f,true))
6780 {
6781 return qe_invalid;
6782 }
6783
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.weaprange,f,true))
6784 {
6785 return qe_invalid;
6786 }
6787
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.weapduration,f,true))
6788 {
6789 return qe_invalid;
6790 }
6791
2/2
✓ Branch 0 taken 56320 times.
✓ Branch 1 taken 5632 times.
61952 for ( int32_t q = 0; q < ITEM_MOVEMENT_PATTERNS; q++ )
6792 {
6793
1/2
✓ Branch 0 taken 56320 times.
✗ Branch 1 not taken.
56320 if(!p_igetl(&tempitem.weap_pattern[q],f,true))
6794 {
6795 return qe_invalid;
6796 }
6797 56320 }
6798 5632 }
6799
6800
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 5632 times.
24576 if ( s_version >= 27 ) //! New itemdata vars for weapon editor. -Z
6801 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6802
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.duplicates,f,true))
6803 {
6804 return qe_invalid;
6805 }
6806
2/2
✓ Branch 0 taken 45056 times.
✓ Branch 1 taken 5632 times.
50688 for ( int32_t q = 0; q < INITIAL_D; q++ )
6807 {
6808
1/2
✓ Branch 0 taken 45056 times.
✗ Branch 1 not taken.
45056 if(!p_igetl(&tempitem.weap_initiald[q],f,true))
6809 {
6810 return qe_invalid;
6811 }
6812 45056 }
6813
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 5632 times.
16896 for ( int32_t q = 0; q < INITIAL_A; q++ )
6814 {
6815
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_getc(&tempitem.weap_initiala[q],f,true))
6816 {
6817 return qe_invalid;
6818 }
6819 11264 }
6820
6821
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_getc(&tempitem.drawlayer,f,true))
6822 {
6823 return qe_invalid;
6824 }
6825
6826
6827
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.hxofs,f,true))
6828 {
6829 return qe_invalid;
6830 }
6831
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.hyofs,f,true))
6832 {
6833 return qe_invalid;
6834 }
6835
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.hxsz,f,true))
6836 {
6837 return qe_invalid;
6838 }
6839
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.hysz,f,true))
6840 {
6841 return qe_invalid;
6842 }
6843
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.hzsz,f,true))
6844 {
6845 return qe_invalid;
6846 }
6847
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.xofs,f,true))
6848 {
6849 return qe_invalid;
6850 }
6851
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.yofs,f,true))
6852 {
6853 return qe_invalid;
6854 }
6855
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.weap_hxofs,f,true))
6856 {
6857 return qe_invalid;
6858 }
6859
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.weap_hyofs,f,true))
6860 {
6861 return qe_invalid;
6862 }
6863
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.weap_hxsz,f,true))
6864 {
6865 return qe_invalid;
6866 }
6867
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.weap_hysz,f,true))
6868 {
6869 return qe_invalid;
6870 }
6871
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.weap_hzsz,f,true))
6872 {
6873 return qe_invalid;
6874 }
6875
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.weap_xofs,f,true))
6876 {
6877 return qe_invalid;
6878 }
6879
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.weap_yofs,f,true))
6880 {
6881 return qe_invalid;
6882 }
6883
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetw(&tempitem.weaponscript,f,true))
6884 {
6885 return qe_invalid;
6886 }
6887
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.wpnsprite,f,true))
6888 {
6889 return qe_invalid;
6890 }
6891 5632 auto num_cost_tmr = (s_version > 52 ? 2 : 1);
6892
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 5632 times.
16896 for(auto q = 0; q < num_cost_tmr; ++q)
6893 {
6894
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&tempitem.magiccosttimer[q],f,true))
6895 {
6896 return qe_invalid;
6897 }
6898 11264 }
6899
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5632 times.
5632 for(auto q = num_cost_tmr; q < 2; ++q)
6900 tempitem.magiccosttimer[q] = 0;
6901 5632 }
6902
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 5632 times.
24576 if ( s_version >= 28 ) //! New itemdata vars for weapon editor. -Z
6903 {
6904 //Item Size FLags, TileWidth, TileHeight
6905
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.overrideFLAGS,f,true))
6906 {
6907 return qe_invalid;
6908 }
6909
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.tilew,f,true))
6910 {
6911 return qe_invalid;
6912 }
6913
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.tileh,f,true))
6914 {
6915 return qe_invalid;
6916 }
6917 5632 }
6918
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 5632 times.
24576 if ( s_version >= 29 ) //! More new vars.
6919 {
6920 //Item Size FLags, TileWidth, TileHeight
6921
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.weapoverrideFLAGS,f,true))
6922 {
6923 return qe_invalid;
6924 }
6925
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.weap_tilew,f,true))
6926 {
6927 return qe_invalid;
6928 }
6929
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.weap_tileh,f,true))
6930 {
6931 return qe_invalid;
6932 }
6933 5632 }
6934
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 5632 times.
24576 if ( s_version >= 30 ) //! More new vars.
6935 {
6936 //Pickup Type
6937
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.pickup,f,true))
6938 {
6939 return qe_invalid;
6940 }
6941 5632 }
6942
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 5632 times.
24576 if ( s_version >= 32 ) //! More new vars.
6943 {
6944 //Pickup Type
6945
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetw(&tempitem.pstring,f,true))
6946 {
6947 return qe_invalid;
6948 }
6949 5632 }
6950
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 5632 times.
24576 if ( s_version >= 33 ) //! More new vars.
6951 {
6952 //Pickup Type
6953
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetw(&tempitem.pickup_string_flags,f,true))
6954 {
6955 return qe_invalid;
6956 }
6957 5632 }
6958
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 5632 times.
24576 if ( s_version >= 34 ) //! cost counter
6959 {
6960
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5632 times.
5632 if(s_version < 53)
6961 {
6962 if(!p_getc(&tempitem.cost_counter[0],f,true))
6963 {
6964 return qe_invalid;
6965 }
6966 }
6967 else
6968 {
6969
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 5632 times.
16896 for(auto q = 0; q < 2; ++q)
6970 {
6971
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_getc(&tempitem.cost_counter[q],f,true))
6972 {
6973 return qe_invalid;
6974 }
6975 11264 }
6976 }
6977 5632 }
6978
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 5632 times.
24576 if ( s_version >= 44 ) //! sprite scripts
6979 {
6980
2/2
✓ Branch 0 taken 45056 times.
✓ Branch 1 taken 5632 times.
50688 for ( int32_t q = 0; q < 8; q++ )
6981 {
6982
2/2
✓ Branch 0 taken 2928640 times.
✓ Branch 1 taken 45056 times.
2973696 for ( int32_t w = 0; w < 65; w++ )
6983 {
6984
1/2
✓ Branch 0 taken 2928640 times.
✗ Branch 1 not taken.
2928640 if(!p_getc(&(tempitem.initD_label[q][w]),f,keepdata))
6985 {
6986 return qe_invalid;
6987 }
6988 2928640 }
6989
2/2
✓ Branch 0 taken 2928640 times.
✓ Branch 1 taken 45056 times.
2973696 for ( int32_t w = 0; w < 65; w++ )
6990 {
6991
1/2
✓ Branch 0 taken 2928640 times.
✗ Branch 1 not taken.
2928640 if(!p_getc(&(tempitem.weapon_initD_label[q][w]),f,keepdata))
6992 {
6993 return qe_invalid;
6994 }
6995 2928640 }
6996
2/2
✓ Branch 0 taken 2928640 times.
✓ Branch 1 taken 45056 times.
2973696 for ( int32_t w = 0; w < 65; w++ )
6997 {
6998
1/2
✓ Branch 0 taken 2928640 times.
✗ Branch 1 not taken.
2928640 if(!p_getc(&(tempitem.sprite_initD_label[q][w]),f,keepdata))
6999 {
7000 return qe_invalid;
7001 }
7002 2928640 }
7003
1/2
✓ Branch 0 taken 45056 times.
✗ Branch 1 not taken.
45056 if(!p_igetl(&(tempitem.sprite_initiald[q]),f,keepdata))
7004 {
7005 return qe_invalid;
7006 }
7007
7008 45056 }
7009
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 5632 times.
16896 for ( int32_t q = 0; q < 2; q++ )
7010 {
7011
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_getc(&(tempitem.sprite_initiala[q]),f,keepdata))
7012 {
7013 return qe_invalid;
7014 }
7015 11264 }
7016 //Pickup Type
7017
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetw(&tempitem.sprite_script,f,true))
7018 {
7019 return qe_invalid;
7020 }
7021 5632 }
7022
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 5632 times.
24576 if ( s_version >= 48 ) //! pickup flags
7023 {
7024
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_getc(&(tempitem.pickupflag),f,keepdata))
7025 {
7026 return qe_invalid;
7027 }
7028 5632 }
7029 24576 }
7030 else
7031 {
7032 210 tempitem.count=-1;
7033 210 tempitem.family=itype_misc;
7034 210 tempitem.flags=tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
7035 210 tempitem.playsound=WAV_SCALE;
7036 210 reset_itembuf(&tempitem,i);
7037 }
7038
7039
1/2
✓ Branch 0 taken 24786 times.
✗ Branch 1 not taken.
24786 if(keepdata==true)
7040 {
7041 24786 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
7042 24786 }
7043 else if(zgpmode)
7044 {
7045 itemsbuf[i].tile=tempitem.tile;
7046 itemsbuf[i].misc_flags=tempitem.misc_flags;
7047 itemsbuf[i].csets=tempitem.csets;
7048 itemsbuf[i].frames=tempitem.frames;
7049 itemsbuf[i].speed=tempitem.speed;
7050 itemsbuf[i].delay=tempitem.delay;
7051 itemsbuf[i].ltm=tempitem.ltm;
7052 }
7053 24786 }
7054
7055 //////////////////////////////////////////////////////
7056 // Now do any updates because of new item additions
7057 // (These can't be done above because items_to_read
7058 // might be too low.)
7059 //////////////////////////////////////////////////////
7060
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata==true)
7061 {
7062
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<MAXITEMS; i++)
7063 {
7064 25344 memcpy(&tempitem, &itemsbuf[i], sizeof(itemdata));
7065
7066 //Account for older quests that didn't have an actual item for the used letter
7067
4/4
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 24576 times.
✓ Branch 2 taken 765 times.
✓ Branch 3 taken 3 times.
25344 if(s_version < 2 && i==iLetterUsed)
7068 {
7069 3 reset_itembuf(&tempitem, iLetterUsed);
7070 3 strcpy(item_string[i],old_item_string[i]);
7071 3 tempitem.tile = itemsbuf[iLetter].tile;
7072 3 tempitem.csets = itemsbuf[iLetter].csets;
7073 3 tempitem.misc_flags = itemsbuf[iLetter].misc_flags;
7074 3 tempitem.frames = itemsbuf[iLetter].frames;
7075 3 tempitem.speed = itemsbuf[iLetter].speed;
7076 3 tempitem.ltm = itemsbuf[iLetter].ltm;
7077 3 }
7078
7079
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 768 times.
25344 if(s_version < 3)
7080 {
7081
3/3
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 699 times.
✓ Branch 2 taken 3 times.
768 switch(i)
7082 {
7083 case iRocsFeather:
7084 case iHoverBoots:
7085 case iSpinScroll:
7086 case iL2SpinScroll:
7087 case iCrossScroll:
7088 case iQuakeScroll:
7089 case iL2QuakeScroll:
7090 case iWhispRing:
7091 case iL2WhispRing:
7092 case iChargeRing:
7093 case iL2ChargeRing:
7094 case iPerilScroll:
7095 case iWalletL3:
7096 case iQuiverL4:
7097 case iBombBagL4:
7098 case iBracelet:
7099 case iL2Bracelet:
7100 case iOldGlove:
7101 case iL2Ladder:
7102 case iWealthMedal:
7103 case iL2WealthMedal:
7104 case iL3WealthMedal:
7105 66 reset_itembuf(&tempitem, i);
7106 66 strcpy(item_string[i],old_item_string[i]);
7107 66 break;
7108
7109 case iSShield:
7110 3 reset_itembuf(&tempitem, i);
7111 3 strcpy(item_string[i],old_item_string[i]);
7112 3 strcpy(item_string[iShield],old_item_string[iShield]);
7113 3 strcpy(item_string[iMShield],old_item_string[iMShield]);
7114 3 break;
7115 }
7116 768 }
7117
7118
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 768 times.
25344 if(s_version < 5)
7119 {
7120
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 747 times.
768 switch(i)
7121 {
7122 case iHeartRing:
7123 case iL2HeartRing:
7124 case iL3HeartRing:
7125 case iMagicRing:
7126 case iL2MagicRing:
7127 case iL3MagicRing:
7128 case iL4MagicRing:
7129 21 reset_itembuf(&tempitem, i);
7130 21 strcpy(item_string[i],old_item_string[i]);
7131 21 break;
7132 }
7133 768 }
7134
7135
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 768 times.
25344 if(s_version < 6) // April 2007: Advanced item editing capabilities.
7136 {
7137
4/4
✓ Branch 0 taken 765 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 762 times.
768 if(i!=iBPotion && i!=iRPotion)
7138 762 tempitem.flags |= get_bit(deprecated_rules,32) ? ITEM_KEEPOLD : 0;
7139
7140
43/43
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 633 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 3 times.
✓ Branch 9 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 11 taken 3 times.
✓ Branch 12 taken 3 times.
✓ Branch 13 taken 3 times.
✓ Branch 14 taken 3 times.
✓ Branch 15 taken 3 times.
✓ Branch 16 taken 3 times.
✓ Branch 17 taken 3 times.
✓ Branch 18 taken 3 times.
✓ Branch 19 taken 3 times.
✓ Branch 20 taken 3 times.
✓ Branch 21 taken 3 times.
✓ Branch 22 taken 3 times.
✓ Branch 23 taken 3 times.
✓ Branch 24 taken 3 times.
✓ Branch 25 taken 3 times.
✓ Branch 26 taken 3 times.
✓ Branch 27 taken 3 times.
✓ Branch 28 taken 3 times.
✓ Branch 29 taken 3 times.
✓ Branch 30 taken 3 times.
✓ Branch 31 taken 3 times.
✓ Branch 32 taken 3 times.
✓ Branch 33 taken 3 times.
✓ Branch 34 taken 3 times.
✓ Branch 35 taken 3 times.
✓ Branch 36 taken 3 times.
✓ Branch 37 taken 3 times.
✓ Branch 38 taken 3 times.
✓ Branch 39 taken 3 times.
✓ Branch 40 taken 3 times.
✓ Branch 41 taken 3 times.
✓ Branch 42 taken 3 times.
768 switch(i)
7141 {
7142 case iTriforce:
7143 3 tempitem.fam_type=1;
7144 3 break;
7145
7146 case iBigTri:
7147 3 tempitem.fam_type=0;
7148 3 break;
7149
7150 case iBombs:
7151 3 tempitem.fam_type=i_bomb;
7152 3 tempitem.power=4;
7153 3 tempitem.wpn=wBOMB;
7154 3 tempitem.wpn2=wBOOM;
7155 3 tempitem.misc1 = 50;
7156
7157
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(get_bit(deprecated_rules,116)) tempitem.misc1 = 200; //qr_SLOWBOMBFUSES
7158
7159 3 break;
7160
7161 case iSBomb:
7162 3 tempitem.fam_type=i_sbomb;
7163 3 tempitem.power=16;
7164 3 tempitem.wpn=wSBOMB;
7165 3 tempitem.wpn2=wSBOOM;
7166 3 tempitem.misc1 = 50;
7167
7168
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(get_bit(deprecated_rules,116)) tempitem.misc1 = 400; //qr_SLOWBOMBFUSES
7169
7170 3 break;
7171
7172 case iBook:
7173
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(get_bit(deprecated_rules, 113))
7174 tempitem.wpn = wFIREMAGIC; //qr_FIREMAGICSPRITE
7175
7176 3 break;
7177
7178 case iSArrow:
7179 3 tempitem.wpn2 = get_bit(deprecated_rules,27) ? wSSPARKLE : 0; //qr_SASPARKLES
7180 3 tempitem.power=4;
7181 3 tempitem.flags|=ITEM_GAMEDATA;
7182 3 tempitem.wpn=wSARROW;
7183 3 break;
7184
7185 case iGArrow:
7186 3 tempitem.wpn2 = get_bit(deprecated_rules,28) ? wGSPARKLE : 0; //qr_GASPARKLES
7187 3 tempitem.power=8;
7188 3 tempitem.flags|=(ITEM_GAMEDATA|ITEM_FLAG1);
7189 3 tempitem.wpn=wGARROW;
7190 3 break;
7191
7192 case iBrang:
7193 3 tempitem.power=0;
7194 3 tempitem.wpn=wBRANG;
7195 3 tempitem.misc1=36;
7196 3 break;
7197
7198 case iMBrang:
7199 3 tempitem.wpn2 = get_bit(deprecated_rules,29) ? wMSPARKLE : 0; //qr_MBSPARKLES
7200 3 tempitem.power=0;
7201 3 tempitem.wpn=wMBRANG;
7202 3 break;
7203
7204 case iFBrang:
7205 3 tempitem.wpn3 = get_bit(deprecated_rules,30) ? wFSPARKLE : 0; //qr_FBSPARKLES
7206 3 tempitem.power=2;
7207 3 tempitem.wpn=wFBRANG;
7208 3 break;
7209
7210 case iBoots:
7211 3 tempitem.cost_amount[0] = get_bit(deprecated_rules,51) ? 1 : 0;
7212 3 tempitem.power=7;
7213 3 break;
7214
7215 case iWand:
7216 3 tempitem.cost_amount[0] = get_bit(deprecated_rules,49) ? 8 : 0;
7217 3 tempitem.power=2;
7218 3 tempitem.wpn=wWAND;
7219 3 tempitem.wpn3=wMAGIC;
7220 3 break;
7221
7222 case iBCandle:
7223 3 tempitem.cost_amount[0] = get_bit(deprecated_rules,50) ? 4 : 0;
7224 3 tempitem.power=1;
7225 3 tempitem.flags|=(ITEM_GAMEDATA|ITEM_FLAG1);
7226 3 tempitem.wpn3=wFIRE;
7227 3 break;
7228
7229 case iRCandle:
7230 3 tempitem.cost_amount[0] = get_bit(deprecated_rules,50) ? 4 : 0;
7231 3 tempitem.power=1;
7232 3 tempitem.wpn3=wFIRE;
7233 3 break;
7234
7235 case iSword:
7236 3 tempitem.power=1;
7237 3 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7238 3 tempitem.wpn=tempitem.wpn3=wSWORD;
7239 3 tempitem.wpn2=wSWORDSLASH;
7240 3 break;
7241
7242 case iWSword:
7243 3 tempitem.power=2;
7244 3 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7245 3 tempitem.wpn=tempitem.wpn3=wWSWORD;
7246 3 tempitem.wpn2=wWSWORDSLASH;
7247 3 break;
7248
7249 case iMSword:
7250 3 tempitem.power=4;
7251 3 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7252 3 tempitem.wpn=tempitem.wpn3=wMSWORD;
7253 3 tempitem.wpn2=wMSWORDSLASH;
7254 3 break;
7255
7256 case iXSword:
7257 3 tempitem.power=8;
7258 3 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7259 3 tempitem.wpn=tempitem.wpn3=wXSWORD;
7260 3 tempitem.wpn2=wXSWORDSLASH;
7261 3 break;
7262
7263 case iNayrusLove:
7264 3 tempitem.flags |= get_bit(deprecated_rules,76) ? ITEM_FLAG1 : 0;
7265 3 tempitem.flags |= get_bit(deprecated_rules,75) ? ITEM_FLAG2 : 0;
7266 3 tempitem.wpn=wNAYRUSLOVE1A;
7267 3 tempitem.wpn2=wNAYRUSLOVE1B;
7268 3 tempitem.wpn3=wNAYRUSLOVES1A;
7269 3 tempitem.wpn4=wNAYRUSLOVES1B;
7270 3 tempitem.wpn6=wNAYRUSLOVE2A;
7271 3 tempitem.wpn7=wNAYRUSLOVE2B;
7272 3 tempitem.wpn8=wNAYRUSLOVES2A;
7273 3 tempitem.wpn9=wNAYRUSLOVES2B;
7274 3 tempitem.wpn5 = iwNayrusLoveShieldFront;
7275 3 tempitem.wpn10 = iwNayrusLoveShieldBack;
7276 3 tempitem.misc1=512;
7277 3 tempitem.cost_amount[0]=64;
7278 3 break;
7279
7280 case iLens:
7281 3 tempitem.misc1=60;
7282 3 tempitem.flags |= get_bit(quest_rules,qr_ENABLEMAGIC) ? 0 : ITEM_RUPEE_MAGIC;
7283 3 tempitem.cost_amount[0] = get_bit(quest_rules,qr_ENABLEMAGIC) ? 2 : 1;
7284 3 break;
7285
7286 case iArrow:
7287 3 tempitem.power=2;
7288 3 tempitem.wpn=wARROW;
7289 3 break;
7290
7291 case iHoverBoots:
7292 3 tempitem.misc1=45;
7293 3 tempitem.wpn=iwHover;
7294 3 break;
7295
7296 case iDinsFire:
7297 3 tempitem.power=8;
7298 3 tempitem.wpn=wDINSFIRE1A;
7299 3 tempitem.wpn2=wDINSFIRE1B;
7300 3 tempitem.wpn3=wDINSFIRES1A;
7301 3 tempitem.wpn4=wDINSFIRES1B;
7302 3 tempitem.misc1 = 32;
7303 3 tempitem.misc2 = 200;
7304 3 tempitem.cost_amount[0]=32;
7305 3 break;
7306
7307 case iFaroresWind:
7308 3 tempitem.cost_amount[0]=32;
7309 3 break;
7310
7311 case iHookshot:
7312 3 tempitem.power=0;
7313 3 tempitem.flags&=~ITEM_FLAG1;
7314 3 tempitem.wpn=wHSHEAD;
7315 3 tempitem.wpn2=wHSCHAIN_H;
7316 3 tempitem.wpn4=wHSHANDLE;
7317 3 tempitem.wpn3=wHSCHAIN_V;
7318 3 tempitem.misc1=50;
7319 3 tempitem.misc2=100;
7320 3 break;
7321
7322 case iLongshot:
7323 3 tempitem.power=0;
7324 3 tempitem.flags&=~ITEM_FLAG1;
7325 3 tempitem.wpn=wLSHEAD;
7326 3 tempitem.wpn2=wLSCHAIN_H;
7327 3 tempitem.wpn4=wLSHANDLE;
7328 3 tempitem.wpn3=wLSCHAIN_V;
7329 3 tempitem.misc1=99;
7330 3 tempitem.misc2=100;
7331 3 break;
7332
7333 case iHammer:
7334 3 tempitem.power=4;
7335 3 tempitem.wpn=wHAMMER;
7336 3 tempitem.wpn2=iwHammerSmack;
7337 3 break;
7338
7339 case iCByrna:
7340 3 tempitem.power=1;
7341 3 tempitem.wpn=wCBYRNA;
7342 3 tempitem.wpn2=wCBYRNASLASH;
7343 3 tempitem.wpn3=wCBYRNAORB;
7344 3 tempitem.misc1=4;
7345 3 tempitem.misc2=16;
7346 3 tempitem.misc3=1;
7347 3 tempitem.cost_amount[0]=1;
7348 3 break;
7349
7350 case iWhistle:
7351 3 tempitem.wpn=wWIND;
7352 3 tempitem.misc1=3;
7353 3 tempitem.flags|=ITEM_FLAG1;
7354 3 break;
7355
7356 case iBRing:
7357 3 tempitem.power=2;
7358 3 tempitem.misc1=spBLUE;
7359 3 break;
7360
7361 case iRRing:
7362 3 tempitem.power=4;
7363 3 tempitem.misc1=spRED;
7364 3 break;
7365
7366 case iGRing:
7367 3 tempitem.power=8;
7368 3 tempitem.misc1=spGOLD;
7369 3 break;
7370
7371 case iSpinScroll:
7372 3 tempitem.power = 2;
7373 3 tempitem.misc1 = 1;
7374 3 break;
7375
7376 case iL2SpinScroll:
7377 3 tempitem.family=itype_spinscroll2;
7378 3 tempitem.fam_type=1;
7379 3 tempitem.cost_amount[0]=8;
7380 3 tempitem.power=2;
7381 3 tempitem.misc1 = 20;
7382 3 break;
7383
7384 case iQuakeScroll:
7385 3 tempitem.misc1=0x10;
7386 3 tempitem.misc2=64;
7387 3 break;
7388
7389 case iL2QuakeScroll:
7390 3 tempitem.family=itype_quakescroll2;
7391 3 tempitem.fam_type=1;
7392 3 tempitem.power = 2;
7393 3 tempitem.misc1=0x20;
7394 3 tempitem.misc2=192;
7395 3 tempitem.cost_amount[0]=8;
7396 3 break;
7397
7398 case iChargeRing:
7399 3 tempitem.misc1=64;
7400 3 tempitem.misc2=128;
7401 3 break;
7402
7403 case iL2ChargeRing:
7404 3 tempitem.misc1=32;
7405 3 tempitem.misc2=64;
7406 3 break;
7407
7408 case iOldGlove:
7409 3 tempitem.flags |= ITEM_FLAG1;
7410
7411 //fallthrough
7412 case iBombBagL4:
7413 case iWalletL3:
7414 case iQuiverL4:
7415 case iBracelet:
7416 15 tempitem.power = 1;
7417 15 break;
7418
7419 case iL2Bracelet:
7420 3 tempitem.power = 2;
7421 3 break;
7422
7423 case iMKey:
7424 3 tempitem.power=0xFF;
7425 3 tempitem.flags |= ITEM_FLAG1;
7426 3 break;
7427 }
7428 768 }
7429
7430
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 768 times.
25344 if(s_version < 7)
7431 {
7432
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 756 times.
768 switch(i)
7433 {
7434 case iStoneAgony:
7435 case iStompBoots:
7436 case iPerilRing:
7437 case iWhimsicalRing:
7438 {
7439 12 reset_itembuf(&tempitem, i);
7440 12 strcpy(item_string[i],old_item_string[i]);
7441 12 break;
7442 }
7443 }
7444 768 }
7445
7446
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 768 times.
25344 if(s_version < 8) // May 2007: Some corrections.
7447 {
7448
7/7
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 744 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 3 times.
768 switch(i)
7449 {
7450 case iMShield:
7451 3 tempitem.misc1|=shFLAME;
7452 3 tempitem.misc2|=shFIREBALL|shMAGIC;
7453
7454
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(get_bit(quest_rules, qr_SWORDMIRROR))
7455 {
7456 tempitem.misc2 |= shSWORD;
7457 }
7458
7459 // fallthrough
7460 case iShield:
7461 6 tempitem.misc1|=shFIREBALL|shSWORD|shMAGIC;
7462
7463 // fallthrough
7464 case iSShield:
7465 9 tempitem.misc1|=shROCK|shARROW|shBRANG|shSCRIPT;
7466
7467
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(get_bit(deprecated_rules,102)) //qr_REFLECTROCKS
7468 {
7469 tempitem.misc2 |= shROCK;
7470 }
7471
7472 9 break;
7473
7474 case iWhispRing:
7475 3 tempitem.power=1;
7476 3 tempitem.flags|=ITEM_GAMEDATA|ITEM_FLAG1;
7477 3 tempitem.misc1 = 3;
7478 3 break;
7479
7480 case iL2WhispRing:
7481 3 tempitem.power=0;
7482 3 tempitem.flags|=ITEM_GAMEDATA|ITEM_FLAG1;
7483 3 tempitem.misc1 = 3;
7484 3 break;
7485
7486 case iL2Ladder:
7487 case iBow:
7488 case iCByrna:
7489 9 tempitem.power = 1;
7490 9 break;
7491 }
7492 768 }
7493
7494
4/4
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 24576 times.
✓ Branch 2 taken 765 times.
✓ Branch 3 taken 3 times.
25344 if(s_version < 9 && i==iClock)
7495 {
7496 3 tempitem.misc1 = get_bit(deprecated_rules, qr_TEMPCLOCKS_DEP) ? 256 : 0;
7497 3 }
7498
7499 //add the misc flag for bomb
7500
4/4
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 24576 times.
✓ Branch 2 taken 765 times.
✓ Branch 3 taken 3 times.
25344 if(s_version < 10 && tempitem.family == itype_bomb)
7501 {
7502 3 tempitem.flags = (tempitem.flags & ~ITEM_FLAG1) | (get_bit(quest_rules, qr_LONGBOMBBOOM_DEP) ? ITEM_FLAG1 : 0);
7503 3 }
7504
7505
4/4
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 24576 times.
✓ Branch 2 taken 762 times.
✓ Branch 3 taken 6 times.
25344 if(s_version < 11 && tempitem.family == itype_triforcepiece)
7506 {
7507 6 tempitem.flags = (tempitem.fam_type ? ITEM_GAMEDATA : 0);
7508 6 tempitem.playsound = (tempitem.fam_type ? WAV_SCALE : WAV_CLEARED);
7509 6 }
7510
7511
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 768 times.
25344 if(s_version < 12) // June 2007: More Misc. attributes.
7512 {
7513
5/5
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 753 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 3 times.
768 switch(i)
7514 {
7515 case iFBrang:
7516 3 tempitem.misc4 |= shFIREBALL|shSWORD|shMAGIC;
7517
7518 //fallthrough
7519 case iMBrang:
7520 6 tempitem.misc3 |= shSWORD|shMAGIC;
7521
7522 //fallthrough
7523 case iHookshot:
7524 case iLongshot:
7525 //fallthrough
7526 12 tempitem.misc3 |= shFIREBALL;
7527
7528 case iBrang:
7529 15 tempitem.misc3 |= shBRANG|shROCK|shARROW;
7530 15 break;
7531 }
7532
7533
16/16
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 282 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 9 times.
✓ Branch 7 taken 6 times.
✓ Branch 8 taken 9 times.
✓ Branch 9 taken 9 times.
✓ Branch 10 taken 411 times.
✓ Branch 11 taken 3 times.
✓ Branch 12 taken 3 times.
✓ Branch 13 taken 3 times.
✓ Branch 14 taken 3 times.
✓ Branch 15 taken 3 times.
768 switch(tempitem.family)
7534 {
7535 case itype_hoverboots:
7536 3 tempitem.usesound = WAV_ZN1HOVER;
7537 3 break;
7538
7539 case itype_wand:
7540 3 tempitem.usesound = WAV_WAND;
7541 3 break;
7542
7543 case itype_book:
7544 3 tempitem.usesound = WAV_FIRE;
7545 3 break;
7546
7547 case itype_arrow:
7548 9 tempitem.usesound = WAV_ARROW;
7549 9 break;
7550
7551 case itype_hookshot:
7552 6 tempitem.usesound = WAV_HOOKSHOT;
7553 6 break;
7554
7555 case itype_brang:
7556 9 tempitem.usesound = WAV_BRANG;
7557 9 break;
7558
7559 case itype_shield:
7560 9 tempitem.usesound = WAV_CHINK;
7561 9 break;
7562
7563 case itype_sword:
7564 411 tempitem.usesound = WAV_SWORD;
7565 411 break;
7566
7567 case itype_whistle:
7568 3 tempitem.usesound = WAV_WHISTLE;
7569 3 break;
7570
7571 case itype_hammer:
7572 3 tempitem.usesound = WAV_HAMMER;
7573 3 break;
7574
7575 case itype_dinsfire:
7576 3 tempitem.usesound = WAV_ZN1DINSFIRE;
7577 3 break;
7578
7579 case itype_faroreswind:
7580 3 tempitem.usesound = WAV_ZN1FARORESWIND;
7581 3 break;
7582
7583 case itype_nayruslove:
7584 3 tempitem.usesound = WAV_ZN1NAYRUSLOVE1;
7585 3 break;
7586
7587 case itype_bomb:
7588 case itype_sbomb:
7589 case itype_quakescroll:
7590 case itype_quakescroll2:
7591 12 tempitem.usesound = WAV_BOMB;
7592 12 break;
7593
7594 case itype_spinscroll:
7595 case itype_spinscroll2:
7596 6 tempitem.usesound = WAV_ZN1SPINATTACK;
7597 6 break;
7598 }
7599 768 }
7600
7601
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 768 times.
25344 if(s_version < 13) // July 2007
7602 {
7603
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 765 times.
768 if(tempitem.family == itype_whistle)
7604 {
7605 3 tempitem.misc1 = (tempitem.power==2 ? 4 : 3);
7606 3 tempitem.power = 1;
7607 3 tempitem.flags|=ITEM_FLAG1;
7608 3 }
7609
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 762 times.
765 else if(tempitem.family == itype_wand)
7610 3 tempitem.flags|=ITEM_FLAG1;
7611
2/2
✓ Branch 0 taken 759 times.
✓ Branch 1 taken 3 times.
762 else if(tempitem.family == itype_book)
7612 {
7613 3 tempitem.flags|=ITEM_FLAG1;
7614 3 tempitem.power = 2;
7615 3 }
7616 768 }
7617
7618
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 768 times.
25344 if(s_version < 14) // August 2007
7619 {
7620
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 762 times.
768 if(tempitem.family == itype_fairy)
7621 {
7622 6 tempitem.usesound = WAV_SCALE;
7623
7624
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(tempitem.fam_type)
7625 6 tempitem.misc3=50;
7626 6 }
7627
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 6 times.
762 else if(tempitem.family == itype_potion)
7628 {
7629 6 tempitem.flags |= ITEM_GAINOLD;
7630 6 }
7631 768 }
7632
7633
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 768 times.
25344 if(s_version < 17) // November 2007
7634 {
7635
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 762 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
768 if(tempitem.family == itype_candle && !tempitem.wpn3)
7636 {
7637 tempitem.wpn3 = wFIRE;
7638 }
7639
4/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 759 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 3 times.
768 else if(tempitem.family == itype_arrow && tempitem.power>4)
7640 {
7641 3 tempitem.flags|=ITEM_FLAG1;
7642 3 }
7643 768 }
7644
7645
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 768 times.
25344 if(s_version < 18) // New Year's Eve 2007
7646 {
7647
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 765 times.
768 if(tempitem.family == itype_whistle)
7648 3 tempitem.misc2 = 8; // Use the Whistle warp ring
7649
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 762 times.
765 else if(tempitem.family == itype_bait)
7650 3 tempitem.misc1 = 768; // Frames until it goes
7651
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 6 times.
762 else if(tempitem.family == itype_triforcepiece)
7652 {
7653
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
6 if(tempitem.flags & ITEM_GAMEDATA)
7654 {
7655 3 tempitem.misc2 = 1; // Cutscene 1
7656 3 tempitem.flags |= ITEM_FLAG1; // Side Warp Out
7657 3 }
7658 6 }
7659 768 }
7660
7661
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 768 times.
25344 if(s_version < 19) // January 2008
7662 {
7663
2/2
✓ Branch 0 taken 765 times.
✓ Branch 1 taken 3 times.
768 if(tempitem.family == itype_nayruslove)
7664 {
7665 3 tempitem.flags |= get_bit(deprecated_rules,qr_NOBOMBPALFLASH+1)?ITEM_FLAG3:0;
7666 3 tempitem.flags |= get_bit(deprecated_rules,qr_NOBOMBPALFLASH+2)?ITEM_FLAG4:0;
7667 3 }
7668 768 }
7669
7670
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 768 times.
25344 if(s_version < 20) // October 2008
7671 {
7672
2/2
✓ Branch 0 taken 765 times.
✓ Branch 1 taken 3 times.
768 if(tempitem.family == itype_nayruslove)
7673 {
7674 3 tempitem.wpn6=wNAYRUSLOVE2A;
7675 3 tempitem.wpn7=wNAYRUSLOVE2B;
7676 3 tempitem.wpn8=wNAYRUSLOVES2A;
7677 3 tempitem.wpn9=wNAYRUSLOVES2B;
7678 3 tempitem.wpn5 = iwNayrusLoveShieldFront;
7679 3 tempitem.wpn10 = iwNayrusLoveShieldBack;
7680 3 }
7681 768 }
7682
7683
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 768 times.
25344 if(s_version < 21) // November 2008
7684 {
7685
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(tempitem.flags & 0x0100) // ITEM_SLASH
7686 {
7687 tempitem.flags &= ~0x0100;
7688
7689 if(tempitem.family == itype_sword ||
7690 tempitem.family == itype_wand ||
7691 tempitem.family == itype_candle ||
7692 tempitem.family == itype_cbyrna)
7693 {
7694 tempitem.flags |= ITEM_FLAG4;
7695 }
7696 }
7697 768 }
7698
7699
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 768 times.
25344 if(s_version < 22) // September 2009
7700 {
7701
4/4
✓ Branch 0 taken 765 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 762 times.
768 if(tempitem.family == itype_sbomb || tempitem.family == itype_bomb)
7702 {
7703 6 tempitem.misc3 = tempitem.power/2;
7704 6 }
7705 768 }
7706
7707
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 768 times.
25344 if(s_version < 23) // March 2011
7708 {
7709
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 765 times.
768 if(tempitem.family == itype_dinsfire)
7710 3 tempitem.wpn5 = wFIRE;
7711
2/2
✓ Branch 0 taken 762 times.
✓ Branch 1 taken 3 times.
765 else if(tempitem.family == itype_book)
7712 3 tempitem.wpn2 = wFIRE;
7713 768 }
7714
7715 // Version 25: Bomb bags were acting as though "super bombs also" was checked
7716 // whether it was or not, and a lot of existing quests depended on the
7717 // incorrect behavior.
7718
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 768 times.
25344 if(s_version < 25) // January 2012
7719 {
7720
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 12 times.
768 if(tempitem.family == itype_bombbag)
7721 12 tempitem.flags |= 16;
7722
7723
2/2
✓ Branch 0 taken 765 times.
✓ Branch 1 taken 3 times.
768 if(tempitem.family == itype_dinsfire)
7724 3 tempitem.flags |= ITEM_FLAG3; // Sideview gravity flag
7725 768 }
7726
7727
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 19712 times.
25344 if( version < 0x254) //Nuke greyed-out flags/values from <=2.53, in case they are used in 2.54/2.55
7728 {
7729
60/60
✓ Branch 0 taken 2017 times.
✓ Branch 1 taken 827 times.
✓ Branch 2 taken 231 times.
✓ Branch 3 taken 970 times.
✓ Branch 4 taken 2157 times.
✓ Branch 5 taken 6474 times.
✓ Branch 6 taken 231 times.
✓ Branch 7 taken 229 times.
✓ Branch 8 taken 192 times.
✓ Branch 9 taken 123 times.
✓ Branch 10 taken 77 times.
✓ Branch 11 taken 154 times.
✓ Branch 12 taken 153 times.
✓ Branch 13 taken 92 times.
✓ Branch 14 taken 231 times.
✓ Branch 15 taken 231 times.
✓ Branch 16 taken 152 times.
✓ Branch 17 taken 231 times.
✓ Branch 18 taken 154 times.
✓ Branch 19 taken 77 times.
✓ Branch 20 taken 154 times.
✓ Branch 21 taken 92 times.
✓ Branch 22 taken 77 times.
✓ Branch 23 taken 231 times.
✓ Branch 24 taken 77 times.
✓ Branch 25 taken 77 times.
✓ Branch 26 taken 154 times.
✓ Branch 27 taken 77 times.
✓ Branch 28 taken 77 times.
✓ Branch 29 taken 77 times.
✓ Branch 30 taken 77 times.
✓ Branch 31 taken 77 times.
✓ Branch 32 taken 92 times.
✓ Branch 33 taken 77 times.
✓ Branch 34 taken 77 times.
✓ Branch 35 taken 77 times.
✓ Branch 36 taken 77 times.
✓ Branch 37 taken 154 times.
✓ Branch 38 taken 308 times.
✓ Branch 39 taken 77 times.
✓ Branch 40 taken 77 times.
✓ Branch 41 taken 136 times.
✓ Branch 42 taken 308 times.
✓ Branch 43 taken 77 times.
✓ Branch 44 taken 77 times.
✓ Branch 45 taken 77 times.
✓ Branch 46 taken 77 times.
✓ Branch 47 taken 77 times.
✓ Branch 48 taken 154 times.
✓ Branch 49 taken 154 times.
✓ Branch 50 taken 77 times.
✓ Branch 51 taken 231 times.
✓ Branch 52 taken 231 times.
✓ Branch 53 taken 308 times.
✓ Branch 54 taken 77 times.
✓ Branch 55 taken 77 times.
✓ Branch 56 taken 77 times.
✓ Branch 57 taken 77 times.
✓ Branch 58 taken 77 times.
✓ Branch 59 taken 77 times.
19712 switch(tempitem.family)
7730 {
7731 case itype_sword:
7732 {
7733 6474 tempitem.flags &= ~(ITEM_FLAG5);
7734 6474 tempitem.misc3 = 0;
7735 6474 tempitem.misc4 = 0;
7736 6474 tempitem.misc5 = 0;
7737 6474 tempitem.misc6 = 0;
7738 6474 tempitem.misc7 = 0;
7739 6474 tempitem.misc8 = 0;
7740 6474 tempitem.misc9 = 0;
7741 6474 tempitem.misc10 = 0;
7742 6474 tempitem.wpn4 = 0;
7743 6474 tempitem.wpn5 = 0;
7744 6474 tempitem.wpn6 = 0;
7745 6474 tempitem.wpn7 = 0;
7746 6474 tempitem.wpn8 = 0;
7747 6474 tempitem.wpn9 = 0;
7748 6474 tempitem.wpn10 = 0;
7749 6474 break;
7750 }
7751 case itype_brang:
7752 {
7753 231 tempitem.flags &= ~(ITEM_FLAG4 | ITEM_FLAG5);
7754 231 tempitem.misc2 = 0;
7755 231 tempitem.misc5 = 0;
7756 231 tempitem.misc6 = 0;
7757 231 tempitem.misc7 = 0;
7758 231 tempitem.misc8 = 0;
7759 231 tempitem.misc9 = 0;
7760 231 tempitem.misc10 = 0;
7761 231 tempitem.wpn4 = 0;
7762 231 tempitem.wpn5 = 0;
7763 231 tempitem.wpn6 = 0;
7764 231 tempitem.wpn7 = 0;
7765 231 tempitem.wpn8 = 0;
7766 231 tempitem.wpn9 = 0;
7767 231 tempitem.wpn10 = 0;
7768 231 break;
7769 }
7770 case itype_arrow:
7771 {
7772 229 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7773 229 tempitem.misc2 = 0;
7774 229 tempitem.misc3 = 0;
7775 229 tempitem.misc4 = 0;
7776 229 tempitem.misc5 = 0;
7777 229 tempitem.misc6 = 0;
7778 229 tempitem.misc7 = 0;
7779 229 tempitem.misc8 = 0;
7780 229 tempitem.misc9 = 0;
7781 229 tempitem.misc10 = 0;
7782 229 tempitem.wpn4 = 0;
7783 229 tempitem.wpn5 = 0;
7784 229 tempitem.wpn6 = 0;
7785 229 tempitem.wpn7 = 0;
7786 229 tempitem.wpn8 = 0;
7787 229 tempitem.wpn9 = 0;
7788 229 tempitem.wpn10 = 0;
7789 229 break;
7790 }
7791 case itype_candle:
7792 {
7793 192 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG5);
7794 192 tempitem.misc1 = 0;
7795 192 tempitem.misc2 = 0;
7796 192 tempitem.misc3 = 0;
7797 192 tempitem.misc4 = 0;
7798 192 tempitem.misc5 = 0;
7799 192 tempitem.misc6 = 0;
7800 192 tempitem.misc7 = 0;
7801 192 tempitem.misc8 = 0;
7802 192 tempitem.misc9 = 0;
7803 192 tempitem.misc10 = 0;
7804 192 tempitem.wpn4 = 0;
7805 192 tempitem.wpn5 = 0;
7806 192 tempitem.wpn6 = 0;
7807 192 tempitem.wpn7 = 0;
7808 192 tempitem.wpn8 = 0;
7809 192 tempitem.wpn9 = 0;
7810 192 tempitem.wpn10 = 0;
7811 192 break;
7812 }
7813 case itype_whistle:
7814 {
7815 123 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7816 123 tempitem.misc3 = 0;
7817 123 tempitem.misc4 = 0;
7818 123 tempitem.misc5 = 0;
7819 123 tempitem.misc6 = 0;
7820 123 tempitem.misc7 = 0;
7821 123 tempitem.misc8 = 0;
7822 123 tempitem.misc9 = 0;
7823 123 tempitem.misc10 = 0;
7824 123 tempitem.wpn2 = 0;
7825 123 tempitem.wpn3 = 0;
7826 123 tempitem.wpn4 = 0;
7827 123 tempitem.wpn5 = 0;
7828 123 tempitem.wpn6 = 0;
7829 123 tempitem.wpn7 = 0;
7830 123 tempitem.wpn8 = 0;
7831 123 tempitem.wpn9 = 0;
7832 123 tempitem.wpn10 = 0;
7833 123 break;
7834 }
7835 case itype_bait:
7836 {
7837 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7838 77 tempitem.misc2 = 0;
7839 77 tempitem.misc3 = 0;
7840 77 tempitem.misc4 = 0;
7841 77 tempitem.misc5 = 0;
7842 77 tempitem.misc6 = 0;
7843 77 tempitem.misc7 = 0;
7844 77 tempitem.misc8 = 0;
7845 77 tempitem.misc9 = 0;
7846 77 tempitem.misc10 = 0;
7847 77 tempitem.wpn2 = 0;
7848 77 tempitem.wpn3 = 0;
7849 77 tempitem.wpn4 = 0;
7850 77 tempitem.wpn5 = 0;
7851 77 tempitem.wpn6 = 0;
7852 77 tempitem.wpn7 = 0;
7853 77 tempitem.wpn8 = 0;
7854 77 tempitem.wpn9 = 0;
7855 77 tempitem.wpn10 = 0;
7856 77 break;
7857 }
7858 case itype_letter:
7859 {
7860 154 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7861 154 tempitem.misc1 = 0;
7862 154 tempitem.misc2 = 0;
7863 154 tempitem.misc3 = 0;
7864 154 tempitem.misc4 = 0;
7865 154 tempitem.misc5 = 0;
7866 154 tempitem.misc6 = 0;
7867 154 tempitem.misc7 = 0;
7868 154 tempitem.misc8 = 0;
7869 154 tempitem.misc9 = 0;
7870 154 tempitem.misc10 = 0;
7871 154 tempitem.wpn = 0;
7872 154 tempitem.wpn2 = 0;
7873 154 tempitem.wpn3 = 0;
7874 154 tempitem.wpn4 = 0;
7875 154 tempitem.wpn5 = 0;
7876 154 tempitem.wpn6 = 0;
7877 154 tempitem.wpn7 = 0;
7878 154 tempitem.wpn8 = 0;
7879 154 tempitem.wpn9 = 0;
7880 154 tempitem.wpn10 = 0;
7881 154 break;
7882 }
7883 case itype_potion:
7884 {
7885 153 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7886 153 tempitem.misc3 = 0;
7887 153 tempitem.misc4 = 0;
7888 153 tempitem.misc5 = 0;
7889 153 tempitem.misc6 = 0;
7890 153 tempitem.misc7 = 0;
7891 153 tempitem.misc8 = 0;
7892 153 tempitem.misc9 = 0;
7893 153 tempitem.misc10 = 0;
7894 153 tempitem.wpn = 0;
7895 153 tempitem.wpn2 = 0;
7896 153 tempitem.wpn3 = 0;
7897 153 tempitem.wpn4 = 0;
7898 153 tempitem.wpn5 = 0;
7899 153 tempitem.wpn6 = 0;
7900 153 tempitem.wpn7 = 0;
7901 153 tempitem.wpn8 = 0;
7902 153 tempitem.wpn9 = 0;
7903 153 tempitem.wpn10 = 0;
7904 153 break;
7905 }
7906 case itype_wand:
7907 {
7908 92 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG5);
7909 92 tempitem.misc1 = 0;
7910 92 tempitem.misc2 = 0;
7911 92 tempitem.misc3 = 0;
7912 92 tempitem.misc4 = 0;
7913 92 tempitem.misc5 = 0;
7914 92 tempitem.misc6 = 0;
7915 92 tempitem.misc7 = 0;
7916 92 tempitem.misc8 = 0;
7917 92 tempitem.misc9 = 0;
7918 92 tempitem.misc10 = 0;
7919 92 tempitem.wpn4 = 0;
7920 92 tempitem.wpn5 = 0;
7921 92 tempitem.wpn6 = 0;
7922 92 tempitem.wpn7 = 0;
7923 92 tempitem.wpn8 = 0;
7924 92 tempitem.wpn9 = 0;
7925 92 tempitem.wpn10 = 0;
7926 92 break;
7927 }
7928 case itype_ring:
7929 {
7930 231 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7931 231 tempitem.misc2 = 0;
7932 231 tempitem.misc3 = 0;
7933 231 tempitem.misc4 = 0;
7934 231 tempitem.misc5 = 0;
7935 231 tempitem.misc6 = 0;
7936 231 tempitem.misc7 = 0;
7937 231 tempitem.misc8 = 0;
7938 231 tempitem.misc9 = 0;
7939 231 tempitem.misc10 = 0;
7940 231 tempitem.wpn = 0;
7941 231 tempitem.wpn2 = 0;
7942 231 tempitem.wpn3 = 0;
7943 231 tempitem.wpn4 = 0;
7944 231 tempitem.wpn5 = 0;
7945 231 tempitem.wpn6 = 0;
7946 231 tempitem.wpn7 = 0;
7947 231 tempitem.wpn8 = 0;
7948 231 tempitem.wpn9 = 0;
7949 231 tempitem.wpn10 = 0;
7950 231 break;
7951 }
7952 case itype_wallet:
7953 {
7954 231 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7955 231 tempitem.misc3 = 0;
7956 231 tempitem.misc4 = 0;
7957 231 tempitem.misc5 = 0;
7958 231 tempitem.misc6 = 0;
7959 231 tempitem.misc7 = 0;
7960 231 tempitem.misc8 = 0;
7961 231 tempitem.misc9 = 0;
7962 231 tempitem.misc10 = 0;
7963 231 tempitem.wpn = 0;
7964 231 tempitem.wpn2 = 0;
7965 231 tempitem.wpn3 = 0;
7966 231 tempitem.wpn4 = 0;
7967 231 tempitem.wpn5 = 0;
7968 231 tempitem.wpn6 = 0;
7969 231 tempitem.wpn7 = 0;
7970 231 tempitem.wpn8 = 0;
7971 231 tempitem.wpn9 = 0;
7972 231 tempitem.wpn10 = 0;
7973 231 break;
7974 }
7975 case itype_amulet:
7976 {
7977 152 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7978 152 tempitem.misc1 = 0;
7979 152 tempitem.misc2 = 0;
7980 152 tempitem.misc3 = 0;
7981 152 tempitem.misc4 = 0;
7982 152 tempitem.misc5 = 0;
7983 152 tempitem.misc6 = 0;
7984 152 tempitem.misc7 = 0;
7985 152 tempitem.misc8 = 0;
7986 152 tempitem.misc9 = 0;
7987 152 tempitem.misc10 = 0;
7988 152 tempitem.wpn = 0;
7989 152 tempitem.wpn2 = 0;
7990 152 tempitem.wpn3 = 0;
7991 152 tempitem.wpn4 = 0;
7992 152 tempitem.wpn5 = 0;
7993 152 tempitem.wpn6 = 0;
7994 152 tempitem.wpn7 = 0;
7995 152 tempitem.wpn8 = 0;
7996 152 tempitem.wpn9 = 0;
7997 152 tempitem.wpn10 = 0;
7998 152 break;
7999 }
8000 case itype_shield:
8001 {
8002 231 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8003 231 tempitem.misc3 = 0;
8004 231 tempitem.misc4 = 0;
8005 231 tempitem.misc5 = 0;
8006 231 tempitem.misc6 = 0;
8007 231 tempitem.misc7 = 0;
8008 231 tempitem.misc8 = 0;
8009 231 tempitem.misc9 = 0;
8010 231 tempitem.misc10 = 0;
8011 231 tempitem.wpn = 0;
8012 231 tempitem.wpn2 = 0;
8013 231 tempitem.wpn3 = 0;
8014 231 tempitem.wpn4 = 0;
8015 231 tempitem.wpn5 = 0;
8016 231 tempitem.wpn6 = 0;
8017 231 tempitem.wpn7 = 0;
8018 231 tempitem.wpn8 = 0;
8019 231 tempitem.wpn9 = 0;
8020 231 tempitem.wpn10 = 0;
8021 231 break;
8022 }
8023 case itype_bow:
8024 {
8025 154 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8026 154 tempitem.misc1 = 0;
8027 154 tempitem.misc2 = 0;
8028 154 tempitem.misc3 = 0;
8029 154 tempitem.misc4 = 0;
8030 154 tempitem.misc5 = 0;
8031 154 tempitem.misc6 = 0;
8032 154 tempitem.misc7 = 0;
8033 154 tempitem.misc8 = 0;
8034 154 tempitem.misc9 = 0;
8035 154 tempitem.misc10 = 0;
8036 154 tempitem.wpn = 0;
8037 154 tempitem.wpn2 = 0;
8038 154 tempitem.wpn3 = 0;
8039 154 tempitem.wpn4 = 0;
8040 154 tempitem.wpn5 = 0;
8041 154 tempitem.wpn6 = 0;
8042 154 tempitem.wpn7 = 0;
8043 154 tempitem.wpn8 = 0;
8044 154 tempitem.wpn9 = 0;
8045 154 tempitem.wpn10 = 0;
8046 154 break;
8047 }
8048 case itype_raft:
8049 {
8050 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8051 77 tempitem.misc1 = 0;
8052 77 tempitem.misc2 = 0;
8053 77 tempitem.misc3 = 0;
8054 77 tempitem.misc4 = 0;
8055 77 tempitem.misc5 = 0;
8056 77 tempitem.misc6 = 0;
8057 77 tempitem.misc7 = 0;
8058 77 tempitem.misc8 = 0;
8059 77 tempitem.misc9 = 0;
8060 77 tempitem.misc10 = 0;
8061 77 tempitem.wpn = 0;
8062 77 tempitem.wpn2 = 0;
8063 77 tempitem.wpn3 = 0;
8064 77 tempitem.wpn4 = 0;
8065 77 tempitem.wpn5 = 0;
8066 77 tempitem.wpn6 = 0;
8067 77 tempitem.wpn7 = 0;
8068 77 tempitem.wpn8 = 0;
8069 77 tempitem.wpn9 = 0;
8070 77 tempitem.wpn10 = 0;
8071 77 break;
8072 }
8073 case itype_ladder:
8074 {
8075 154 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8076 154 tempitem.misc1 = 0;
8077 154 tempitem.misc2 = 0;
8078 154 tempitem.misc3 = 0;
8079 154 tempitem.misc4 = 0;
8080 154 tempitem.misc5 = 0;
8081 154 tempitem.misc6 = 0;
8082 154 tempitem.misc7 = 0;
8083 154 tempitem.misc8 = 0;
8084 154 tempitem.misc9 = 0;
8085 154 tempitem.misc10 = 0;
8086 154 tempitem.wpn = 0;
8087 154 tempitem.wpn2 = 0;
8088 154 tempitem.wpn3 = 0;
8089 154 tempitem.wpn4 = 0;
8090 154 tempitem.wpn5 = 0;
8091 154 tempitem.wpn6 = 0;
8092 154 tempitem.wpn7 = 0;
8093 154 tempitem.wpn8 = 0;
8094 154 tempitem.wpn9 = 0;
8095 154 tempitem.wpn10 = 0;
8096 154 break;
8097 }
8098 case itype_book:
8099 {
8100 92 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8101 92 tempitem.misc1 = 0;
8102 92 tempitem.misc2 = 0;
8103 92 tempitem.misc3 = 0;
8104 92 tempitem.misc4 = 0;
8105 92 tempitem.misc5 = 0;
8106 92 tempitem.misc6 = 0;
8107 92 tempitem.misc7 = 0;
8108 92 tempitem.misc8 = 0;
8109 92 tempitem.misc9 = 0;
8110 92 tempitem.misc10 = 0;
8111 92 tempitem.wpn3 = 0;
8112 92 tempitem.wpn4 = 0;
8113 92 tempitem.wpn5 = 0;
8114 92 tempitem.wpn6 = 0;
8115 92 tempitem.wpn7 = 0;
8116 92 tempitem.wpn8 = 0;
8117 92 tempitem.wpn9 = 0;
8118 92 tempitem.wpn10 = 0;
8119 92 break;
8120 }
8121 case itype_magickey:
8122 {
8123 77 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8124 77 tempitem.misc1 = 0;
8125 77 tempitem.misc2 = 0;
8126 77 tempitem.misc3 = 0;
8127 77 tempitem.misc4 = 0;
8128 77 tempitem.misc5 = 0;
8129 77 tempitem.misc6 = 0;
8130 77 tempitem.misc7 = 0;
8131 77 tempitem.misc8 = 0;
8132 77 tempitem.misc9 = 0;
8133 77 tempitem.misc10 = 0;
8134 77 tempitem.wpn = 0;
8135 77 tempitem.wpn2 = 0;
8136 77 tempitem.wpn3 = 0;
8137 77 tempitem.wpn4 = 0;
8138 77 tempitem.wpn5 = 0;
8139 77 tempitem.wpn6 = 0;
8140 77 tempitem.wpn7 = 0;
8141 77 tempitem.wpn8 = 0;
8142 77 tempitem.wpn9 = 0;
8143 77 tempitem.wpn10 = 0;
8144 77 break;
8145 }
8146 case itype_bracelet:
8147 {
8148 231 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8149 231 tempitem.misc1 = 0;
8150 231 tempitem.misc2 = 0;
8151 231 tempitem.misc3 = 0;
8152 231 tempitem.misc4 = 0;
8153 231 tempitem.misc5 = 0;
8154 231 tempitem.misc6 = 0;
8155 231 tempitem.misc7 = 0;
8156 231 tempitem.misc8 = 0;
8157 231 tempitem.misc9 = 0;
8158 231 tempitem.misc10 = 0;
8159 231 tempitem.wpn = 0;
8160 231 tempitem.wpn2 = 0;
8161 231 tempitem.wpn3 = 0;
8162 231 tempitem.wpn4 = 0;
8163 231 tempitem.wpn5 = 0;
8164 231 tempitem.wpn6 = 0;
8165 231 tempitem.wpn7 = 0;
8166 231 tempitem.wpn8 = 0;
8167 231 tempitem.wpn9 = 0;
8168 231 tempitem.wpn10 = 0;
8169 231 break;
8170 }
8171 case itype_flippers:
8172 {
8173 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8174 77 tempitem.misc1 = 0;
8175 77 tempitem.misc2 = 0;
8176 77 tempitem.misc3 = 0;
8177 77 tempitem.misc4 = 0;
8178 77 tempitem.misc5 = 0;
8179 77 tempitem.misc6 = 0;
8180 77 tempitem.misc7 = 0;
8181 77 tempitem.misc8 = 0;
8182 77 tempitem.misc9 = 0;
8183 77 tempitem.misc10 = 0;
8184 77 tempitem.wpn = 0;
8185 77 tempitem.wpn2 = 0;
8186 77 tempitem.wpn3 = 0;
8187 77 tempitem.wpn4 = 0;
8188 77 tempitem.wpn5 = 0;
8189 77 tempitem.wpn6 = 0;
8190 77 tempitem.wpn7 = 0;
8191 77 tempitem.wpn8 = 0;
8192 77 tempitem.wpn9 = 0;
8193 77 tempitem.wpn10 = 0;
8194 77 break;
8195 }
8196 case itype_boots:
8197 {
8198 77 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8199 77 tempitem.misc1 = 0;
8200 77 tempitem.misc2 = 0;
8201 77 tempitem.misc3 = 0;
8202 77 tempitem.misc4 = 0;
8203 77 tempitem.misc5 = 0;
8204 77 tempitem.misc6 = 0;
8205 77 tempitem.misc7 = 0;
8206 77 tempitem.misc8 = 0;
8207 77 tempitem.misc9 = 0;
8208 77 tempitem.misc10 = 0;
8209 77 tempitem.wpn = 0;
8210 77 tempitem.wpn2 = 0;
8211 77 tempitem.wpn3 = 0;
8212 77 tempitem.wpn4 = 0;
8213 77 tempitem.wpn5 = 0;
8214 77 tempitem.wpn6 = 0;
8215 77 tempitem.wpn7 = 0;
8216 77 tempitem.wpn8 = 0;
8217 77 tempitem.wpn9 = 0;
8218 77 tempitem.wpn10 = 0;
8219 77 break;
8220 }
8221 case itype_hookshot:
8222 {
8223 154 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8224 154 tempitem.misc5 = 0;
8225 154 tempitem.misc6 = 0;
8226 154 tempitem.misc7 = 0;
8227 154 tempitem.misc8 = 0;
8228 154 tempitem.misc9 = 0;
8229 154 tempitem.misc10 = 0;
8230 154 tempitem.wpn5 = 0;
8231 154 tempitem.wpn6 = 0;
8232 154 tempitem.wpn7 = 0;
8233 154 tempitem.wpn8 = 0;
8234 154 tempitem.wpn9 = 0;
8235 154 tempitem.wpn10 = 0;
8236 154 break;
8237 }
8238 case itype_lens:
8239 {
8240 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8241 77 tempitem.misc2 = 0;
8242 77 tempitem.misc3 = 0;
8243 77 tempitem.misc4 = 0;
8244 77 tempitem.misc5 = 0;
8245 77 tempitem.misc6 = 0;
8246 77 tempitem.misc7 = 0;
8247 77 tempitem.misc8 = 0;
8248 77 tempitem.misc9 = 0;
8249 77 tempitem.misc10 = 0;
8250 77 tempitem.wpn = 0;
8251 77 tempitem.wpn2 = 0;
8252 77 tempitem.wpn3 = 0;
8253 77 tempitem.wpn4 = 0;
8254 77 tempitem.wpn5 = 0;
8255 77 tempitem.wpn6 = 0;
8256 77 tempitem.wpn7 = 0;
8257 77 tempitem.wpn8 = 0;
8258 77 tempitem.wpn9 = 0;
8259 77 tempitem.wpn10 = 0;
8260 77 break;
8261 }
8262 case itype_hammer:
8263 {
8264 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8265 77 tempitem.misc1 = 0;
8266 77 tempitem.misc2 = 0;
8267 77 tempitem.misc3 = 0;
8268 77 tempitem.misc4 = 0;
8269 77 tempitem.misc5 = 0;
8270 77 tempitem.misc6 = 0;
8271 77 tempitem.misc7 = 0;
8272 77 tempitem.misc8 = 0;
8273 77 tempitem.misc9 = 0;
8274 77 tempitem.misc10 = 0;
8275 77 tempitem.wpn3 = 0;
8276 77 tempitem.wpn4 = 0;
8277 77 tempitem.wpn5 = 0;
8278 77 tempitem.wpn6 = 0;
8279 77 tempitem.wpn7 = 0;
8280 77 tempitem.wpn8 = 0;
8281 77 tempitem.wpn9 = 0;
8282 77 tempitem.wpn10 = 0;
8283 77 break;
8284 }
8285 case itype_dinsfire:
8286 {
8287 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG4 | ITEM_FLAG5);
8288 77 tempitem.misc3 = 0;
8289 77 tempitem.misc4 = 0;
8290 77 tempitem.misc5 = 0;
8291 77 tempitem.misc6 = 0;
8292 77 tempitem.misc7 = 0;
8293 77 tempitem.misc8 = 0;
8294 77 tempitem.misc9 = 0;
8295 77 tempitem.misc10 = 0;
8296 77 tempitem.wpn6 = 0;
8297 77 tempitem.wpn7 = 0;
8298 77 tempitem.wpn8 = 0;
8299 77 tempitem.wpn9 = 0;
8300 77 tempitem.wpn10 = 0;
8301 77 break;
8302 }
8303 case itype_faroreswind:
8304 {
8305 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8306 77 tempitem.misc2 = 0;
8307 77 tempitem.misc3 = 0;
8308 77 tempitem.misc4 = 0;
8309 77 tempitem.misc5 = 0;
8310 77 tempitem.misc6 = 0;
8311 77 tempitem.misc7 = 0;
8312 77 tempitem.misc8 = 0;
8313 77 tempitem.misc9 = 0;
8314 77 tempitem.misc10 = 0;
8315 77 tempitem.wpn = 0;
8316 77 tempitem.wpn2 = 0;
8317 77 tempitem.wpn3 = 0;
8318 77 tempitem.wpn4 = 0;
8319 77 tempitem.wpn5 = 0;
8320 77 tempitem.wpn6 = 0;
8321 77 tempitem.wpn7 = 0;
8322 77 tempitem.wpn8 = 0;
8323 77 tempitem.wpn9 = 0;
8324 77 tempitem.wpn10 = 0;
8325 77 break;
8326 }
8327 case itype_nayruslove:
8328 {
8329 77 tempitem.flags &= ~ (ITEM_FLAG5);
8330 77 tempitem.misc2 = 0;
8331 77 tempitem.misc3 = 0;
8332 77 tempitem.misc4 = 0;
8333 77 tempitem.misc5 = 0;
8334 77 tempitem.misc6 = 0;
8335 77 tempitem.misc7 = 0;
8336 77 tempitem.misc8 = 0;
8337 77 tempitem.misc9 = 0;
8338 77 tempitem.misc10 = 0;
8339 77 break;
8340 }
8341 case itype_bomb:
8342 {
8343 92 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8344 92 tempitem.misc4 = 0;
8345 92 tempitem.misc5 = 0;
8346 92 tempitem.misc6 = 0;
8347 92 tempitem.misc7 = 0;
8348 92 tempitem.misc8 = 0;
8349 92 tempitem.misc9 = 0;
8350 92 tempitem.misc10 = 0;
8351 92 tempitem.wpn3 = 0;
8352 92 tempitem.wpn4 = 0;
8353 92 tempitem.wpn5 = 0;
8354 92 tempitem.wpn6 = 0;
8355 92 tempitem.wpn7 = 0;
8356 92 tempitem.wpn8 = 0;
8357 92 tempitem.wpn9 = 0;
8358 92 tempitem.wpn10 = 0;
8359 92 break;
8360 }
8361 case itype_sbomb:
8362 {
8363 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8364 77 tempitem.misc4 = 0;
8365 77 tempitem.misc5 = 0;
8366 77 tempitem.misc6 = 0;
8367 77 tempitem.misc7 = 0;
8368 77 tempitem.misc8 = 0;
8369 77 tempitem.misc9 = 0;
8370 77 tempitem.misc10 = 0;
8371 77 tempitem.wpn3 = 0;
8372 77 tempitem.wpn4 = 0;
8373 77 tempitem.wpn5 = 0;
8374 77 tempitem.wpn6 = 0;
8375 77 tempitem.wpn7 = 0;
8376 77 tempitem.wpn8 = 0;
8377 77 tempitem.wpn9 = 0;
8378 77 tempitem.wpn10 = 0;
8379 77 break;
8380 }
8381 case itype_clock:
8382 {
8383 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8384 77 tempitem.misc2 = 0;
8385 77 tempitem.misc3 = 0;
8386 77 tempitem.misc4 = 0;
8387 77 tempitem.misc5 = 0;
8388 77 tempitem.misc6 = 0;
8389 77 tempitem.misc7 = 0;
8390 77 tempitem.misc8 = 0;
8391 77 tempitem.misc9 = 0;
8392 77 tempitem.misc10 = 0;
8393 77 tempitem.wpn = 0;
8394 77 tempitem.wpn2 = 0;
8395 77 tempitem.wpn3 = 0;
8396 77 tempitem.wpn4 = 0;
8397 77 tempitem.wpn5 = 0;
8398 77 tempitem.wpn6 = 0;
8399 77 tempitem.wpn7 = 0;
8400 77 tempitem.wpn8 = 0;
8401 77 tempitem.wpn9 = 0;
8402 77 tempitem.wpn10 = 0;
8403 77 break;
8404 }
8405 case itype_key:
8406 {
8407 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8408 77 tempitem.misc1 = 0;
8409 77 tempitem.misc2 = 0;
8410 77 tempitem.misc3 = 0;
8411 77 tempitem.misc4 = 0;
8412 77 tempitem.misc5 = 0;
8413 77 tempitem.misc6 = 0;
8414 77 tempitem.misc7 = 0;
8415 77 tempitem.misc8 = 0;
8416 77 tempitem.misc9 = 0;
8417 77 tempitem.misc10 = 0;
8418 77 tempitem.wpn = 0;
8419 77 tempitem.wpn2 = 0;
8420 77 tempitem.wpn3 = 0;
8421 77 tempitem.wpn4 = 0;
8422 77 tempitem.wpn5 = 0;
8423 77 tempitem.wpn6 = 0;
8424 77 tempitem.wpn7 = 0;
8425 77 tempitem.wpn8 = 0;
8426 77 tempitem.wpn9 = 0;
8427 77 tempitem.wpn10 = 0;
8428 77 break;
8429 }
8430 case itype_magiccontainer:
8431 {
8432 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8433 77 tempitem.misc1 = 0;
8434 77 tempitem.misc2 = 0;
8435 77 tempitem.misc3 = 0;
8436 77 tempitem.misc4 = 0;
8437 77 tempitem.misc5 = 0;
8438 77 tempitem.misc6 = 0;
8439 77 tempitem.misc7 = 0;
8440 77 tempitem.misc8 = 0;
8441 77 tempitem.misc9 = 0;
8442 77 tempitem.misc10 = 0;
8443 77 tempitem.wpn = 0;
8444 77 tempitem.wpn2 = 0;
8445 77 tempitem.wpn3 = 0;
8446 77 tempitem.wpn4 = 0;
8447 77 tempitem.wpn5 = 0;
8448 77 tempitem.wpn6 = 0;
8449 77 tempitem.wpn7 = 0;
8450 77 tempitem.wpn8 = 0;
8451 77 tempitem.wpn9 = 0;
8452 77 tempitem.wpn10 = 0;
8453 77 break;
8454 }
8455 case itype_triforcepiece:
8456 {
8457 154 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8458 154 tempitem.misc3 = 0;
8459 154 tempitem.misc4 = 0;
8460 154 tempitem.misc5 = 0;
8461 154 tempitem.misc6 = 0;
8462 154 tempitem.misc7 = 0;
8463 154 tempitem.misc8 = 0;
8464 154 tempitem.misc9 = 0;
8465 154 tempitem.misc10 = 0;
8466 154 tempitem.wpn = 0;
8467 154 tempitem.wpn2 = 0;
8468 154 tempitem.wpn3 = 0;
8469 154 tempitem.wpn4 = 0;
8470 154 tempitem.wpn5 = 0;
8471 154 tempitem.wpn6 = 0;
8472 154 tempitem.wpn7 = 0;
8473 154 tempitem.wpn8 = 0;
8474 154 tempitem.wpn9 = 0;
8475 154 tempitem.wpn10 = 0;
8476 154 break;
8477 }
8478 case itype_map: case itype_compass: case itype_bosskey:
8479 {
8480 231 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8481 231 tempitem.misc1 = 0;
8482 231 tempitem.misc2 = 0;
8483 231 tempitem.misc3 = 0;
8484 231 tempitem.misc4 = 0;
8485 231 tempitem.misc5 = 0;
8486 231 tempitem.misc6 = 0;
8487 231 tempitem.misc7 = 0;
8488 231 tempitem.misc8 = 0;
8489 231 tempitem.misc9 = 0;
8490 231 tempitem.misc10 = 0;
8491 231 tempitem.wpn = 0;
8492 231 tempitem.wpn2 = 0;
8493 231 tempitem.wpn3 = 0;
8494 231 tempitem.wpn4 = 0;
8495 231 tempitem.wpn5 = 0;
8496 231 tempitem.wpn6 = 0;
8497 231 tempitem.wpn7 = 0;
8498 231 tempitem.wpn8 = 0;
8499 231 tempitem.wpn9 = 0;
8500 231 tempitem.wpn10 = 0;
8501 231 break;
8502 }
8503 case itype_quiver:
8504 {
8505 308 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8506 308 tempitem.misc3 = 0;
8507 308 tempitem.misc4 = 0;
8508 308 tempitem.misc5 = 0;
8509 308 tempitem.misc6 = 0;
8510 308 tempitem.misc7 = 0;
8511 308 tempitem.misc8 = 0;
8512 308 tempitem.misc9 = 0;
8513 308 tempitem.misc10 = 0;
8514 308 tempitem.wpn = 0;
8515 308 tempitem.wpn2 = 0;
8516 308 tempitem.wpn3 = 0;
8517 308 tempitem.wpn4 = 0;
8518 308 tempitem.wpn5 = 0;
8519 308 tempitem.wpn6 = 0;
8520 308 tempitem.wpn7 = 0;
8521 308 tempitem.wpn8 = 0;
8522 308 tempitem.wpn9 = 0;
8523 308 tempitem.wpn10 = 0;
8524 308 break;
8525 }
8526 case itype_lkey:
8527 {
8528 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8529 77 tempitem.misc1 = 0;
8530 77 tempitem.misc2 = 0;
8531 77 tempitem.misc3 = 0;
8532 77 tempitem.misc4 = 0;
8533 77 tempitem.misc5 = 0;
8534 77 tempitem.misc6 = 0;
8535 77 tempitem.misc7 = 0;
8536 77 tempitem.misc8 = 0;
8537 77 tempitem.misc9 = 0;
8538 77 tempitem.misc10 = 0;
8539 77 tempitem.wpn = 0;
8540 77 tempitem.wpn2 = 0;
8541 77 tempitem.wpn3 = 0;
8542 77 tempitem.wpn4 = 0;
8543 77 tempitem.wpn5 = 0;
8544 77 tempitem.wpn6 = 0;
8545 77 tempitem.wpn7 = 0;
8546 77 tempitem.wpn8 = 0;
8547 77 tempitem.wpn9 = 0;
8548 77 tempitem.wpn10 = 0;
8549 77 break;
8550 }
8551 case itype_cbyrna:
8552 {
8553 77 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG5);
8554 77 tempitem.misc4 = 0;
8555 77 tempitem.misc5 = 0;
8556 77 tempitem.misc6 = 0;
8557 77 tempitem.misc7 = 0;
8558 77 tempitem.misc8 = 0;
8559 77 tempitem.misc9 = 0;
8560 77 tempitem.misc10 = 0;
8561 77 tempitem.wpn6 = 0;
8562 77 tempitem.wpn7 = 0;
8563 77 tempitem.wpn8 = 0;
8564 77 tempitem.wpn9 = 0;
8565 77 tempitem.wpn10 = 0;
8566 77 break;
8567 }
8568 case itype_rupee: case itype_arrowammo:
8569 {
8570 970 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8571 970 tempitem.misc1 = 0;
8572 970 tempitem.misc2 = 0;
8573 970 tempitem.misc3 = 0;
8574 970 tempitem.misc4 = 0;
8575 970 tempitem.misc5 = 0;
8576 970 tempitem.misc6 = 0;
8577 970 tempitem.misc7 = 0;
8578 970 tempitem.misc8 = 0;
8579 970 tempitem.misc9 = 0;
8580 970 tempitem.misc10 = 0;
8581 970 tempitem.wpn = 0;
8582 970 tempitem.wpn2 = 0;
8583 970 tempitem.wpn3 = 0;
8584 970 tempitem.wpn4 = 0;
8585 970 tempitem.wpn5 = 0;
8586 970 tempitem.wpn6 = 0;
8587 970 tempitem.wpn7 = 0;
8588 970 tempitem.wpn8 = 0;
8589 970 tempitem.wpn9 = 0;
8590 970 tempitem.wpn10 = 0;
8591 970 break;
8592 }
8593 case itype_fairy:
8594 {
8595 136 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8596 136 tempitem.misc4 = 0;
8597 136 tempitem.misc5 = 0;
8598 136 tempitem.misc6 = 0;
8599 136 tempitem.misc7 = 0;
8600 136 tempitem.misc8 = 0;
8601 136 tempitem.misc9 = 0;
8602 136 tempitem.misc10 = 0;
8603 136 tempitem.wpn = 0;
8604 136 tempitem.wpn2 = 0;
8605 136 tempitem.wpn3 = 0;
8606 136 tempitem.wpn4 = 0;
8607 136 tempitem.wpn5 = 0;
8608 136 tempitem.wpn6 = 0;
8609 136 tempitem.wpn7 = 0;
8610 136 tempitem.wpn8 = 0;
8611 136 tempitem.wpn9 = 0;
8612 136 tempitem.wpn10 = 0;
8613 136 break;
8614 }
8615 case itype_magic: case itype_heart: case itype_heartcontainer: case itype_heartpiece: case itype_killem: case itype_bombammo:
8616 {
8617 827 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8618 827 tempitem.misc1 = 0;
8619 827 tempitem.misc2 = 0;
8620 827 tempitem.misc3 = 0;
8621 827 tempitem.misc4 = 0;
8622 827 tempitem.misc5 = 0;
8623 827 tempitem.misc6 = 0;
8624 827 tempitem.misc7 = 0;
8625 827 tempitem.misc8 = 0;
8626 827 tempitem.misc9 = 0;
8627 827 tempitem.misc10 = 0;
8628 827 tempitem.wpn = 0;
8629 827 tempitem.wpn2 = 0;
8630 827 tempitem.wpn3 = 0;
8631 827 tempitem.wpn4 = 0;
8632 827 tempitem.wpn5 = 0;
8633 827 tempitem.wpn6 = 0;
8634 827 tempitem.wpn7 = 0;
8635 827 tempitem.wpn8 = 0;
8636 827 tempitem.wpn9 = 0;
8637 827 tempitem.wpn10 = 0;
8638 827 break;
8639 }
8640 case itype_bombbag:
8641 {
8642 308 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8643 308 tempitem.misc3 = 0;
8644 308 tempitem.misc4 = 0;
8645 308 tempitem.misc5 = 0;
8646 308 tempitem.misc6 = 0;
8647 308 tempitem.misc7 = 0;
8648 308 tempitem.misc8 = 0;
8649 308 tempitem.misc9 = 0;
8650 308 tempitem.misc10 = 0;
8651 308 tempitem.wpn = 0;
8652 308 tempitem.wpn2 = 0;
8653 308 tempitem.wpn3 = 0;
8654 308 tempitem.wpn4 = 0;
8655 308 tempitem.wpn5 = 0;
8656 308 tempitem.wpn6 = 0;
8657 308 tempitem.wpn7 = 0;
8658 308 tempitem.wpn8 = 0;
8659 308 tempitem.wpn9 = 0;
8660 308 tempitem.wpn10 = 0;
8661 308 break;
8662 }
8663 case itype_rocs:
8664 {
8665 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8666 77 tempitem.misc1 = 0;
8667 77 tempitem.misc2 = 0;
8668 77 tempitem.misc3 = 0;
8669 77 tempitem.misc4 = 0;
8670 77 tempitem.misc5 = 0;
8671 77 tempitem.misc6 = 0;
8672 77 tempitem.misc7 = 0;
8673 77 tempitem.misc8 = 0;
8674 77 tempitem.misc9 = 0;
8675 77 tempitem.misc10 = 0;
8676 77 tempitem.wpn = 0;
8677 77 tempitem.wpn2 = 0;
8678 77 tempitem.wpn3 = 0;
8679 77 tempitem.wpn4 = 0;
8680 77 tempitem.wpn5 = 0;
8681 77 tempitem.wpn6 = 0;
8682 77 tempitem.wpn7 = 0;
8683 77 tempitem.wpn8 = 0;
8684 77 tempitem.wpn9 = 0;
8685 77 tempitem.wpn10 = 0;
8686 77 break;
8687 }
8688 case itype_hoverboots:
8689 {
8690 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8691 77 tempitem.misc2 = 0;
8692 77 tempitem.misc3 = 0;
8693 77 tempitem.misc4 = 0;
8694 77 tempitem.misc5 = 0;
8695 77 tempitem.misc6 = 0;
8696 77 tempitem.misc7 = 0;
8697 77 tempitem.misc8 = 0;
8698 77 tempitem.misc9 = 0;
8699 77 tempitem.misc10 = 0;
8700 77 tempitem.wpn2 = 0;
8701 77 tempitem.wpn3 = 0;
8702 77 tempitem.wpn4 = 0;
8703 77 tempitem.wpn5 = 0;
8704 77 tempitem.wpn6 = 0;
8705 77 tempitem.wpn7 = 0;
8706 77 tempitem.wpn8 = 0;
8707 77 tempitem.wpn9 = 0;
8708 77 tempitem.wpn10 = 0;
8709 77 break;
8710 }
8711 case itype_spinscroll:
8712 {
8713 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8714 77 tempitem.misc2 = 0;
8715 77 tempitem.misc3 = 0;
8716 77 tempitem.misc4 = 0;
8717 77 tempitem.misc5 = 0;
8718 77 tempitem.misc6 = 0;
8719 77 tempitem.misc7 = 0;
8720 77 tempitem.misc8 = 0;
8721 77 tempitem.misc9 = 0;
8722 77 tempitem.misc10 = 0;
8723 77 tempitem.wpn = 0;
8724 77 tempitem.wpn2 = 0;
8725 77 tempitem.wpn3 = 0;
8726 77 tempitem.wpn4 = 0;
8727 77 tempitem.wpn5 = 0;
8728 77 tempitem.wpn6 = 0;
8729 77 tempitem.wpn7 = 0;
8730 77 tempitem.wpn8 = 0;
8731 77 tempitem.wpn9 = 0;
8732 77 tempitem.wpn10 = 0;
8733 77 break;
8734 }
8735 case itype_crossscroll:
8736 {
8737 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8738 77 tempitem.misc1 = 0;
8739 77 tempitem.misc2 = 0;
8740 77 tempitem.misc3 = 0;
8741 77 tempitem.misc4 = 0;
8742 77 tempitem.misc5 = 0;
8743 77 tempitem.misc6 = 0;
8744 77 tempitem.misc7 = 0;
8745 77 tempitem.misc8 = 0;
8746 77 tempitem.misc9 = 0;
8747 77 tempitem.misc10 = 0;
8748 77 tempitem.wpn = 0;
8749 77 tempitem.wpn2 = 0;
8750 77 tempitem.wpn3 = 0;
8751 77 tempitem.wpn4 = 0;
8752 77 tempitem.wpn5 = 0;
8753 77 tempitem.wpn6 = 0;
8754 77 tempitem.wpn7 = 0;
8755 77 tempitem.wpn8 = 0;
8756 77 tempitem.wpn9 = 0;
8757 77 tempitem.wpn10 = 0;
8758 77 break;
8759 }
8760 case itype_quakescroll:
8761 {
8762 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8763 77 tempitem.misc3 = 0;
8764 77 tempitem.misc4 = 0;
8765 77 tempitem.misc5 = 0;
8766 77 tempitem.misc6 = 0;
8767 77 tempitem.misc7 = 0;
8768 77 tempitem.misc8 = 0;
8769 77 tempitem.misc9 = 0;
8770 77 tempitem.misc10 = 0;
8771 77 tempitem.wpn = 0;
8772 77 tempitem.wpn2 = 0;
8773 77 tempitem.wpn3 = 0;
8774 77 tempitem.wpn4 = 0;
8775 77 tempitem.wpn5 = 0;
8776 77 tempitem.wpn6 = 0;
8777 77 tempitem.wpn7 = 0;
8778 77 tempitem.wpn8 = 0;
8779 77 tempitem.wpn9 = 0;
8780 77 tempitem.wpn10 = 0;
8781 77 break;
8782 }
8783 case itype_whispring:
8784 {
8785 154 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8786 154 tempitem.misc2 = 0;
8787 154 tempitem.misc3 = 0;
8788 154 tempitem.misc4 = 0;
8789 154 tempitem.misc5 = 0;
8790 154 tempitem.misc6 = 0;
8791 154 tempitem.misc7 = 0;
8792 154 tempitem.misc8 = 0;
8793 154 tempitem.misc9 = 0;
8794 154 tempitem.misc10 = 0;
8795 154 tempitem.wpn = 0;
8796 154 tempitem.wpn2 = 0;
8797 154 tempitem.wpn3 = 0;
8798 154 tempitem.wpn4 = 0;
8799 154 tempitem.wpn5 = 0;
8800 154 tempitem.wpn6 = 0;
8801 154 tempitem.wpn7 = 0;
8802 154 tempitem.wpn8 = 0;
8803 154 tempitem.wpn9 = 0;
8804 154 tempitem.wpn10 = 0;
8805 154 break;
8806 }
8807 case itype_chargering:
8808 {
8809 154 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8810 154 tempitem.misc3 = 0;
8811 154 tempitem.misc4 = 0;
8812 154 tempitem.misc5 = 0;
8813 154 tempitem.misc6 = 0;
8814 154 tempitem.misc7 = 0;
8815 154 tempitem.misc8 = 0;
8816 154 tempitem.misc9 = 0;
8817 154 tempitem.misc10 = 0;
8818 154 tempitem.wpn = 0;
8819 154 tempitem.wpn2 = 0;
8820 154 tempitem.wpn3 = 0;
8821 154 tempitem.wpn4 = 0;
8822 154 tempitem.wpn5 = 0;
8823 154 tempitem.wpn6 = 0;
8824 154 tempitem.wpn7 = 0;
8825 154 tempitem.wpn8 = 0;
8826 154 tempitem.wpn9 = 0;
8827 154 tempitem.wpn10 = 0;
8828 154 break;
8829 }
8830 case itype_perilscroll:
8831 {
8832 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8833 77 tempitem.misc2 = 0;
8834 77 tempitem.misc3 = 0;
8835 77 tempitem.misc4 = 0;
8836 77 tempitem.misc5 = 0;
8837 77 tempitem.misc6 = 0;
8838 77 tempitem.misc7 = 0;
8839 77 tempitem.misc8 = 0;
8840 77 tempitem.misc9 = 0;
8841 77 tempitem.misc10 = 0;
8842 77 tempitem.wpn = 0;
8843 77 tempitem.wpn2 = 0;
8844 77 tempitem.wpn3 = 0;
8845 77 tempitem.wpn4 = 0;
8846 77 tempitem.wpn5 = 0;
8847 77 tempitem.wpn6 = 0;
8848 77 tempitem.wpn7 = 0;
8849 77 tempitem.wpn8 = 0;
8850 77 tempitem.wpn9 = 0;
8851 77 tempitem.wpn10 = 0;
8852 77 break;
8853 }
8854 case itype_wealthmedal:
8855 {
8856 231 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8857 231 tempitem.misc2 = 0;
8858 231 tempitem.misc3 = 0;
8859 231 tempitem.misc4 = 0;
8860 231 tempitem.misc5 = 0;
8861 231 tempitem.misc6 = 0;
8862 231 tempitem.misc7 = 0;
8863 231 tempitem.misc8 = 0;
8864 231 tempitem.misc9 = 0;
8865 231 tempitem.misc10 = 0;
8866 231 tempitem.wpn = 0;
8867 231 tempitem.wpn2 = 0;
8868 231 tempitem.wpn3 = 0;
8869 231 tempitem.wpn4 = 0;
8870 231 tempitem.wpn5 = 0;
8871 231 tempitem.wpn6 = 0;
8872 231 tempitem.wpn7 = 0;
8873 231 tempitem.wpn8 = 0;
8874 231 tempitem.wpn9 = 0;
8875 231 tempitem.wpn10 = 0;
8876 231 break;
8877 }
8878 case itype_heartring:
8879 {
8880 231 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8881 231 tempitem.misc3 = 0;
8882 231 tempitem.misc4 = 0;
8883 231 tempitem.misc5 = 0;
8884 231 tempitem.misc6 = 0;
8885 231 tempitem.misc7 = 0;
8886 231 tempitem.misc8 = 0;
8887 231 tempitem.misc9 = 0;
8888 231 tempitem.misc10 = 0;
8889 231 tempitem.wpn = 0;
8890 231 tempitem.wpn2 = 0;
8891 231 tempitem.wpn3 = 0;
8892 231 tempitem.wpn4 = 0;
8893 231 tempitem.wpn5 = 0;
8894 231 tempitem.wpn6 = 0;
8895 231 tempitem.wpn7 = 0;
8896 231 tempitem.wpn8 = 0;
8897 231 tempitem.wpn9 = 0;
8898 231 tempitem.wpn10 = 0;
8899 231 break;
8900 }
8901 case itype_magicring:
8902 {
8903 308 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8904 308 tempitem.misc3 = 0;
8905 308 tempitem.misc4 = 0;
8906 308 tempitem.misc5 = 0;
8907 308 tempitem.misc6 = 0;
8908 308 tempitem.misc7 = 0;
8909 308 tempitem.misc8 = 0;
8910 308 tempitem.misc9 = 0;
8911 308 tempitem.misc10 = 0;
8912 308 tempitem.wpn = 0;
8913 308 tempitem.wpn2 = 0;
8914 308 tempitem.wpn3 = 0;
8915 308 tempitem.wpn4 = 0;
8916 308 tempitem.wpn5 = 0;
8917 308 tempitem.wpn6 = 0;
8918 308 tempitem.wpn7 = 0;
8919 308 tempitem.wpn8 = 0;
8920 308 tempitem.wpn9 = 0;
8921 308 tempitem.wpn10 = 0;
8922 308 break;
8923 }
8924 case itype_spinscroll2:
8925 {
8926 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8927 77 tempitem.misc2 = 0;
8928 77 tempitem.misc3 = 0;
8929 77 tempitem.misc4 = 0;
8930 77 tempitem.misc5 = 0;
8931 77 tempitem.misc6 = 0;
8932 77 tempitem.misc7 = 0;
8933 77 tempitem.misc8 = 0;
8934 77 tempitem.misc9 = 0;
8935 77 tempitem.misc10 = 0;
8936 77 tempitem.wpn = 0;
8937 77 tempitem.wpn2 = 0;
8938 77 tempitem.wpn3 = 0;
8939 77 tempitem.wpn4 = 0;
8940 77 tempitem.wpn5 = 0;
8941 77 tempitem.wpn6 = 0;
8942 77 tempitem.wpn7 = 0;
8943 77 tempitem.wpn8 = 0;
8944 77 tempitem.wpn9 = 0;
8945 77 tempitem.wpn10 = 0;
8946 77 break;
8947 }
8948 case itype_quakescroll2:
8949 {
8950 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8951 77 tempitem.misc3 = 0;
8952 77 tempitem.misc4 = 0;
8953 77 tempitem.misc5 = 0;
8954 77 tempitem.misc6 = 0;
8955 77 tempitem.misc7 = 0;
8956 77 tempitem.misc8 = 0;
8957 77 tempitem.misc9 = 0;
8958 77 tempitem.misc10 = 0;
8959 77 tempitem.wpn = 0;
8960 77 tempitem.wpn2 = 0;
8961 77 tempitem.wpn3 = 0;
8962 77 tempitem.wpn4 = 0;
8963 77 tempitem.wpn5 = 0;
8964 77 tempitem.wpn6 = 0;
8965 77 tempitem.wpn7 = 0;
8966 77 tempitem.wpn8 = 0;
8967 77 tempitem.wpn9 = 0;
8968 77 tempitem.wpn10 = 0;
8969 77 break;
8970 }
8971 case itype_agony:
8972 {
8973 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8974 77 tempitem.misc2 = 0;
8975 77 tempitem.misc3 = 0;
8976 77 tempitem.misc4 = 0;
8977 77 tempitem.misc5 = 0;
8978 77 tempitem.misc6 = 0;
8979 77 tempitem.misc7 = 0;
8980 77 tempitem.misc8 = 0;
8981 77 tempitem.misc9 = 0;
8982 77 tempitem.misc10 = 0;
8983 77 tempitem.wpn = 0;
8984 77 tempitem.wpn2 = 0;
8985 77 tempitem.wpn3 = 0;
8986 77 tempitem.wpn4 = 0;
8987 77 tempitem.wpn5 = 0;
8988 77 tempitem.wpn6 = 0;
8989 77 tempitem.wpn7 = 0;
8990 77 tempitem.wpn8 = 0;
8991 77 tempitem.wpn9 = 0;
8992 77 tempitem.wpn10 = 0;
8993 77 break;
8994 }
8995 case itype_stompboots:
8996 {
8997 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8998 77 tempitem.misc1 = 0;
8999 77 tempitem.misc2 = 0;
9000 77 tempitem.misc3 = 0;
9001 77 tempitem.misc4 = 0;
9002 77 tempitem.misc5 = 0;
9003 77 tempitem.misc6 = 0;
9004 77 tempitem.misc7 = 0;
9005 77 tempitem.misc8 = 0;
9006 77 tempitem.misc9 = 0;
9007 77 tempitem.misc10 = 0;
9008 77 tempitem.wpn = 0;
9009 77 tempitem.wpn2 = 0;
9010 77 tempitem.wpn3 = 0;
9011 77 tempitem.wpn4 = 0;
9012 77 tempitem.wpn5 = 0;
9013 77 tempitem.wpn6 = 0;
9014 77 tempitem.wpn7 = 0;
9015 77 tempitem.wpn8 = 0;
9016 77 tempitem.wpn9 = 0;
9017 77 tempitem.wpn10 = 0;
9018 77 break;
9019 }
9020 case itype_whimsicalring:
9021 {
9022 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9023 77 tempitem.misc2 = 0;
9024 77 tempitem.misc3 = 0;
9025 77 tempitem.misc4 = 0;
9026 77 tempitem.misc5 = 0;
9027 77 tempitem.misc6 = 0;
9028 77 tempitem.misc7 = 0;
9029 77 tempitem.misc8 = 0;
9030 77 tempitem.misc9 = 0;
9031 77 tempitem.misc10 = 0;
9032 77 tempitem.wpn = 0;
9033 77 tempitem.wpn2 = 0;
9034 77 tempitem.wpn3 = 0;
9035 77 tempitem.wpn4 = 0;
9036 77 tempitem.wpn5 = 0;
9037 77 tempitem.wpn6 = 0;
9038 77 tempitem.wpn7 = 0;
9039 77 tempitem.wpn8 = 0;
9040 77 tempitem.wpn9 = 0;
9041 77 tempitem.wpn10 = 0;
9042 77 break;
9043 }
9044 case itype_perilring:
9045 {
9046 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9047 77 tempitem.misc2 = 0;
9048 77 tempitem.misc3 = 0;
9049 77 tempitem.misc4 = 0;
9050 77 tempitem.misc5 = 0;
9051 77 tempitem.misc6 = 0;
9052 77 tempitem.misc7 = 0;
9053 77 tempitem.misc8 = 0;
9054 77 tempitem.misc9 = 0;
9055 77 tempitem.misc10 = 0;
9056 77 tempitem.wpn = 0;
9057 77 tempitem.wpn2 = 0;
9058 77 tempitem.wpn3 = 0;
9059 77 tempitem.wpn4 = 0;
9060 77 tempitem.wpn5 = 0;
9061 77 tempitem.wpn6 = 0;
9062 77 tempitem.wpn7 = 0;
9063 77 tempitem.wpn8 = 0;
9064 77 tempitem.wpn9 = 0;
9065 77 tempitem.wpn10 = 0;
9066 77 break;
9067 }
9068 case itype_custom1: case itype_custom2: case itype_custom3: case itype_custom4: case itype_custom5:
9069 case itype_custom6: case itype_custom7: case itype_custom8: case itype_custom9: case itype_custom10:
9070 case itype_custom11: case itype_custom12: case itype_custom13: case itype_custom14: case itype_custom15:
9071 case itype_custom16: case itype_custom17: case itype_custom18: case itype_custom19: case itype_custom20:
9072 case itype_bowandarrow: case itype_letterpotion: case itype_misc:
9073 {
9074 2017 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9075 2017 tempitem.misc1 = 0;
9076 2017 tempitem.misc2 = 0;
9077 2017 tempitem.misc3 = 0;
9078 2017 tempitem.misc4 = 0;
9079 2017 tempitem.misc5 = 0;
9080 2017 tempitem.misc6 = 0;
9081 2017 tempitem.misc7 = 0;
9082 2017 tempitem.misc8 = 0;
9083 2017 tempitem.misc9 = 0;
9084 2017 tempitem.misc10 = 0;
9085 2017 tempitem.wpn = 0;
9086 2017 tempitem.wpn2 = 0;
9087 2017 tempitem.wpn3 = 0;
9088 2017 tempitem.wpn4 = 0;
9089 2017 tempitem.wpn5 = 0;
9090 2017 tempitem.wpn6 = 0;
9091 2017 tempitem.wpn7 = 0;
9092 2017 tempitem.wpn8 = 0;
9093 2017 tempitem.wpn9 = 0;
9094 2017 tempitem.wpn10 = 0;
9095 2017 break;
9096 }
9097 }
9098 19712 }
9099 //Port quest rules to items
9100
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 19712 times.
25344 if( s_version <= 31)
9101 {
9102
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 19620 times.
19712 if(tempitem.family == itype_bomb)
9103 {
9104
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 86 times.
92 if ( get_bit(quest_rules,qr_OUCHBOMBS) ) tempitem.flags |= ITEM_FLAG2;
9105 86 else tempitem.flags &= ~ ITEM_FLAG2;
9106 92 }
9107
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 19543 times.
19620 else if(tempitem.family == itype_sbomb)
9108 {
9109
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 71 times.
77 if ( get_bit(quest_rules,qr_OUCHBOMBS) ) tempitem.flags |= ITEM_FLAG2;
9110 71 else tempitem.flags &= ~ ITEM_FLAG2;
9111 77 }
9112
9113
2/2
✓ Branch 0 taken 231 times.
✓ Branch 1 taken 19312 times.
19543 else if(tempitem.family == itype_brang)
9114 {
9115
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 231 times.
231 if ( get_bit(quest_rules,qr_BRANGPICKUP) ) tempitem.flags |= ITEM_FLAG4;
9116 231 else tempitem.flags &= ~ ITEM_FLAG4;
9117 231 }
9118
2/2
✓ Branch 0 taken 19220 times.
✓ Branch 1 taken 92 times.
19312 else if(tempitem.family == itype_wand)
9119 {
9120
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 90 times.
92 if ( get_bit(quest_rules,qr_NOWANDMELEE) ) tempitem.flags |= ITEM_FLAG3;
9121 90 else tempitem.flags &= ~ ITEM_FLAG3;
9122 92 }
9123 19712 }
9124
9125 //Port quest rules to items
9126
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 19712 times.
25344 if( s_version <= 37)
9127 {
9128
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 19635 times.
19712 if(tempitem.family == itype_flippers)
9129 {
9130
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if ( (get_bit(quest_rules,qr_NODIVING)) ) tempitem.flags |= ITEM_FLAG1;
9131 77 else tempitem.flags &= ~ ITEM_FLAG1;
9132 77 }
9133
2/2
✓ Branch 0 taken 13161 times.
✓ Branch 1 taken 6474 times.
19635 else if(tempitem.family == itype_sword)
9134 {
9135
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 6405 times.
6474 if ( (get_bit(quest_rules,qr_QUICKSWORD)) ) tempitem.flags |= ITEM_FLAG5;
9136 6405 else tempitem.flags &= ~ ITEM_FLAG5;
9137 6474 }
9138
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 13069 times.
13161 else if(tempitem.family == itype_wand)
9139 {
9140
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 89 times.
92 if ( (get_bit(quest_rules,qr_QUICKSWORD)) ) tempitem.flags |= ITEM_FLAG5;
9141 89 else tempitem.flags &= ~ ITEM_FLAG5;
9142 92 }
9143
4/4
✓ Branch 0 taken 12977 times.
✓ Branch 1 taken 92 times.
✓ Branch 2 taken 192 times.
✓ Branch 3 taken 12785 times.
13069 else if(tempitem.family == itype_book || tempitem.family == itype_candle)
9144 {
9145 //@Emily: What was qrFIREPROOFHERO2 again, and does that also need to enable this?
9146
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 218 times.
284 if ( (get_bit(quest_rules,qr_FIREPROOFHERO)) ) tempitem.flags |= ITEM_FLAG3;
9147 218 else tempitem.flags &= ~ ITEM_FLAG3;
9148 284 }
9149 19712 }
9150
9151
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 19712 times.
25344 if( s_version < 38)
9152 {
9153
4/4
✓ Branch 0 taken 19481 times.
✓ Branch 1 taken 231 times.
✓ Branch 2 taken 154 times.
✓ Branch 3 taken 19327 times.
19712 if(tempitem.family == itype_brang || tempitem.family == itype_hookshot)
9154 {
9155
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 385 times.
385 if(get_bit(quest_rules,qr_BRANGPICKUP)) tempitem.flags |= ITEM_FLAG4;
9156 385 else tempitem.flags &= ~ITEM_FLAG4;
9157
9158
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 375 times.
385 if(get_bit(quest_rules,qr_Z3BRANG_HSHOT)) tempitem.flags |= ITEM_FLAG5 | ITEM_FLAG6;
9159 375 else tempitem.flags &= ~(ITEM_FLAG5|ITEM_FLAG6);
9160 385 }
9161
2/2
✓ Branch 0 taken 19098 times.
✓ Branch 1 taken 229 times.
19327 else if(tempitem.family == itype_arrow)
9162 {
9163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 229 times.
229 if(get_bit(quest_rules,qr_BRANGPICKUP)) tempitem.flags |= ITEM_FLAG4;
9164 229 else tempitem.flags &= ~ITEM_FLAG4;
9165
9166
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 225 times.
229 if(get_bit(quest_rules,qr_Z3BRANG_HSHOT)) tempitem.flags &= ~ITEM_FLAG2;
9167 225 else tempitem.flags |= ITEM_FLAG2;
9168 229 }
9169 19712 }
9170
9171
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 19712 times.
25344 if( s_version < 39)
9172 {
9173
6/6
✓ Branch 0 taken 19635 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 19543 times.
✓ Branch 3 taken 92 times.
✓ Branch 4 taken 192 times.
✓ Branch 5 taken 19351 times.
19712 if(tempitem.family == itype_dinsfire || tempitem.family == itype_book || tempitem.family == itype_candle)
9174 {
9175
2/2
✓ Branch 0 taken 349 times.
✓ Branch 1 taken 12 times.
361 if(get_bit(quest_rules,qr_TEMPCANDLELIGHT)) tempitem.flags |= ITEM_FLAG5;
9176 349 else tempitem.flags &= ~ITEM_FLAG5;
9177 361 }
9178
2/2
✓ Branch 0 taken 153 times.
✓ Branch 1 taken 19198 times.
19351 else if(tempitem.family == itype_potion)
9179 {
9180
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 147 times.
153 if(get_bit(quest_rules,qr_NONBUBBLEMEDICINE))
9181 {
9182 6 tempitem.flags &= ~(ITEM_FLAG3|ITEM_FLAG4);
9183 6 }
9184 else
9185 {
9186 147 tempitem.flags |= ITEM_FLAG3;
9187
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 62 times.
147 if(get_bit(quest_rules,qr_ITEMBUBBLE))tempitem.flags |= ITEM_FLAG4;
9188 62 else tempitem.flags &= ~ITEM_FLAG4;
9189 }
9190 153 }
9191
2/2
✓ Branch 0 taken 19044 times.
✓ Branch 1 taken 154 times.
19198 else if(tempitem.family == itype_triforcepiece)
9192 {
9193
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 142 times.
154 if(get_bit(quest_rules,qr_NONBUBBLETRIFORCE))
9194 {
9195 12 tempitem.flags |= ITEM_FLAG3;
9196
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 6 times.
12 if(get_bit(quest_rules,qr_ITEMBUBBLE))tempitem.flags |= ITEM_FLAG4;
9197 6 else tempitem.flags &= ~ITEM_FLAG4;
9198 12 }
9199 else
9200 {
9201 142 tempitem.flags &= ~(ITEM_FLAG3|ITEM_FLAG4);
9202 }
9203 154 }
9204 19712 }
9205
9206
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 19712 times.
25344 if( s_version < 40)
9207 {
9208
4/4
✓ Branch 0 taken 19481 times.
✓ Branch 1 taken 231 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 19404 times.
19712 if(tempitem.family == itype_ring || tempitem.family == itype_perilring)
9209 {
9210
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 288 times.
308 if(get_bit(quest_rules,qr_RINGAFFECTDAMAGE))tempitem.flags |= ITEM_FLAG1;
9211 288 else tempitem.flags &= ~ITEM_FLAG1;
9212 308 }
9213
8/8
✓ Branch 0 taken 19212 times.
✓ Branch 1 taken 192 times.
✓ Branch 2 taken 12738 times.
✓ Branch 3 taken 6474 times.
✓ Branch 4 taken 12646 times.
✓ Branch 5 taken 92 times.
✓ Branch 6 taken 77 times.
✓ Branch 7 taken 12569 times.
19404 else if(tempitem.family == itype_candle || tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_cbyrna)
9214 {
9215
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 6754 times.
6835 if(get_bit(quest_rules,qr_SLASHFLIPFIX))tempitem.flags |= ITEM_FLAG8;
9216 6754 else tempitem.flags &= ~ITEM_FLAG8;
9217 6835 }
9218
6/6
✓ Branch 0 taken 13238 times.
✓ Branch 1 taken 6474 times.
✓ Branch 2 taken 13146 times.
✓ Branch 3 taken 92 times.
✓ Branch 4 taken 77 times.
✓ Branch 5 taken 13069 times.
19712 if(tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_hammer)
9219 {
9220
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6643 times.
6643 if(get_bit(quest_rules,qr_NOITEMMELEE))tempitem.flags |= ITEM_FLAG7;
9221 6643 else tempitem.flags &= ~ITEM_FLAG7;
9222 6643 }
9223
2/2
✓ Branch 0 taken 12992 times.
✓ Branch 1 taken 77 times.
13069 else if(tempitem.family == itype_cbyrna)
9224 {
9225 77 tempitem.flags |= ITEM_FLAG7;
9226 77 }
9227 19712 }
9228
9229
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 19712 times.
25344 if( s_version < 41 )
9230 {
9231
2/2
✓ Branch 0 taken 13238 times.
✓ Branch 1 taken 6474 times.
19712 if(tempitem.family == itype_sword)
9232 {
9233
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 6405 times.
6474 if(get_bit(quest_rules,qr_SWORDMIRROR))tempitem.flags |= ITEM_FLAG9;
9234 6405 else tempitem.flags &= ~ITEM_FLAG9;
9235
9236
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 6405 times.
6474 if(get_bit(quest_rules,qr_SLOWCHARGINGWALK))tempitem.flags |= ITEM_FLAG10;
9237 6405 else tempitem.flags &= ~ITEM_FLAG10;
9238 6474 }
9239 19712 }
9240
9241
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 19712 times.
25344 if( s_version < 42 )
9242 {
9243
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 19620 times.
19712 if(tempitem.family == itype_wand)
9244 {
9245
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 90 times.
92 if(get_bit(quest_rules,qr_NOWANDMELEE))tempitem.flags |= ITEM_FLAG3;
9246 90 else tempitem.flags &= ~ITEM_FLAG3;
9247
9248 92 tempitem.flags &= ~ITEM_FLAG6;
9249 92 }
9250
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 19543 times.
19620 else if(tempitem.family == itype_hammer)
9251 {
9252 77 tempitem.flags &= ~ITEM_FLAG3;
9253 77 }
9254
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 19466 times.
19543 else if(tempitem.family == itype_cbyrna)
9255 {
9256 77 tempitem.flags |= ITEM_FLAG3;
9257
9258 77 tempitem.flags &= ~ITEM_FLAG6;
9259 77 }
9260
2/2
✓ Branch 0 taken 12992 times.
✓ Branch 1 taken 6474 times.
19466 else if(tempitem.family == itype_sword)
9261 {
9262
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6474 times.
6474 if(get_bit(quest_rules,qr_MELEEMAGICCOST))tempitem.flags |= ITEM_FLAG6;
9263 6474 else tempitem.flags &= ~ITEM_FLAG6;
9264 6474 }
9265 19712 }
9266
9267
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 19712 times.
25344 if( s_version < 43 )
9268 {
9269
2/2
✓ Branch 0 taken 19589 times.
✓ Branch 1 taken 123 times.
19712 if(tempitem.family == itype_whistle)
9270 {
9271
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 120 times.
123 if(get_bit(quest_rules,qr_WHIRLWINDMIRROR))tempitem.flags |= ITEM_FLAG3;
9272 120 else tempitem.flags &= ~ITEM_FLAG3;
9273 123 }
9274 19712 }
9275
9276
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 19712 times.
25344 if( s_version < 45 )
9277 {
9278
2/2
✓ Branch 0 taken 19635 times.
✓ Branch 1 taken 77 times.
19712 if(tempitem.family == itype_flippers)
9279 {
9280 77 tempitem.misc1 = 50; //Dive length, default 50 frames -V
9281 77 tempitem.misc2 = 30; //Dive cooldown, default 30 frames -V
9282 77 }
9283 19712 }
9284
9285
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 19712 times.
25344 if( s_version < 46 )
9286 {
9287
2/2
✓ Branch 0 taken 19635 times.
✓ Branch 1 taken 77 times.
19712 if(tempitem.family == itype_raft)
9288 {
9289 77 tempitem.misc1 = 1; //Rafting speed modifier; default 1. Negative slows, positive speeds.
9290 77 }
9291 19712 }
9292
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 19712 times.
25344 if ( s_version < 34 ) //! set the default counter for older quests.
9293 {
9294
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 19643 times.
19712 if ( (tempitem.flags & ITEM_RUPEE_MAGIC) )
9295 {
9296 69 tempitem.cost_counter[0] = 1;
9297 69 }
9298 else
9299 {
9300
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 17595 times.
19643 if(get_bit(quest_rules,qr_ENABLEMAGIC))
9301 2048 tempitem.cost_counter[0] = 4;
9302 else
9303 {
9304 17595 tempitem.cost_amount[0] = 0;
9305 17595 tempitem.cost_counter[0] = -1;
9306 }
9307 }
9308 19712 }
9309
9310
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 19712 times.
25344 if ( s_version < 35 ) //new Lens of Truth flags
9311 {
9312
2/2
✓ Branch 0 taken 19635 times.
✓ Branch 1 taken 77 times.
19712 if ( tempitem.family == itype_lens )
9313 {
9314
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 74 times.
77 if ( get_bit(quest_rules,qr_RAFTLENS) )
9315 {
9316 3 tempitem.flags |= ITEM_FLAG4;
9317 3 }
9318
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 38 times.
77 if ( get_bit(quest_rules,qr_LENSHINTS) )
9319 {
9320 39 tempitem.flags |= ITEM_FLAG1;
9321 39 }
9322
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 73 times.
77 if ( get_bit(quest_rules,qr_LENSSEESENEMIES) )
9323 {
9324 4 tempitem.flags |= ITEM_FLAG5;
9325 4 }
9326 77 }
9327 19712 }
9328
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 19712 times.
25344 if ( s_version < 44 ) //InitD Labels and Sprite Script Data
9329 {
9330
2/2
✓ Branch 0 taken 157696 times.
✓ Branch 1 taken 19712 times.
177408 for ( int32_t q = 0; q < 8; q++ )
9331 {
9332 157696 sprintf(tempitem.initD_label[q],"InitD[%d]",q);
9333 157696 sprintf(tempitem.weapon_initD_label[q],"InitD[%d]",q);
9334 157696 sprintf(tempitem.sprite_initD_label[q],"InitD[%d]",q);
9335 157696 tempitem.sprite_initiald[q] = 0;
9336 157696 }
9337
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 19712 times.
59136 for ( int32_t q = 0; q < 2; q++ ) tempitem.sprite_initiala[q] = 0;
9338 19712 tempitem.sprite_script = 0;
9339 19712 }
9340
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 19712 times.
25344 if ( s_version < 47 ) //InitD Labels and Sprite Script Data
9341 {
9342 19712 tempitem.pickupflag = 0;
9343 19712 }
9344
9345
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 19712 times.
25344 if( s_version < 51 )
9346 {
9347
2/2
✓ Branch 0 taken 19520 times.
✓ Branch 1 taken 192 times.
19712 if( tempitem.family == itype_candle )
9348 {
9349 192 tempitem.misc4 = 50; //Step speed
9350 192 }
9351 19712 }
9352
9353
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 19712 times.
25344 if( s_version < 52 )
9354 {
9355
2/2
✓ Branch 0 taken 19481 times.
✓ Branch 1 taken 231 times.
19712 if( tempitem.family == itype_shield )
9356 231 tempitem.flags |= ITEM_FLAG1; //'Block Front' flag
9357 19712 }
9358
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 19712 times.
25344 if(s_version < 53)
9359 {
9360
4/4
✓ Branch 0 taken 19314 times.
✓ Branch 1 taken 229 times.
✓ Branch 2 taken 92 times.
✓ Branch 3 taken 77 times.
19712 switch(tempitem.family)
9361 {
9362 case itype_arrow:
9363 229 tempitem.cost_counter[1] = crARROWS;
9364 229 tempitem.cost_amount[1] = 1;
9365 229 break;
9366 case itype_bomb:
9367 92 tempitem.cost_counter[1] = crBOMBS;
9368 92 tempitem.cost_amount[1] = 1;
9369 92 break;
9370 case itype_sbomb:
9371 77 tempitem.cost_counter[1] = crSBOMBS;
9372 77 tempitem.cost_amount[1] = 1;
9373 77 break;
9374 default:
9375 19314 tempitem.cost_counter[1] = crNONE;
9376 19314 tempitem.cost_amount[1] = 0;
9377 19314 }
9378 19712 tempitem.magiccosttimer[1] = 0;
9379 19712 }
9380
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
25344 if( s_version < 54 )
9381 {
9382
2/2
✓ Branch 0 taken 25244 times.
✓ Branch 1 taken 100 times.
25344 if( tempitem.family == itype_flippers )
9383 100 tempitem.misc3 = INT_BTN_A; //'Block Front' flag
9384 25344 }
9385
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
25344 if(s_version < 55)
9386 {
9387
3/3
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 198 times.
✓ Branch 2 taken 24948 times.
25344 switch(tempitem.family)
9388 {
9389 case itype_spinscroll:
9390 case itype_quakescroll:
9391 198 tempitem.usesound2 = WAV_ZN1CHARGE;
9392 198 break;
9393 case itype_spinscroll2:
9394 case itype_quakescroll2:
9395 198 tempitem.usesound2 = WAV_ZN1CHARGE2;
9396 198 break;
9397 }
9398 25344 }
9399
9400
2/2
✓ Branch 0 taken 402 times.
✓ Branch 1 taken 24942 times.
25344 if(tempitem.fam_type==0) // Always do this
9401 402 tempitem.fam_type=1;
9402
9403 25344 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
9404 25344 }
9405 99 }
9406
9407 99 return 0;
9408 99 }
9409
9410 static bool did_init_def_items = false;
9411 50445 void init_def_items()
9412 {
9413
2/2
✓ Branch 0 taken 50416 times.
✓ Branch 1 taken 29 times.
50445 if(did_init_def_items) return;
9414 29 did_init_def_items = true;
9415 29 default_items[3].cost_counter[1] = crBOMBS;
9416 29 default_items[13].cost_counter[1] = crARROWS;
9417 29 default_items[14].cost_counter[1] = crARROWS;
9418 29 default_items[48].cost_counter[1] = crSBOMBS;
9419 29 default_items[57].cost_counter[1] = crARROWS;
9420 50445 }
9421 50445 void reset_itembuf(itemdata *item, int32_t id)
9422 {
9423 50445 init_def_items();
9424
2/2
✓ Branch 0 taken 22035 times.
✓ Branch 1 taken 28410 times.
50445 if(id<iLast)
9425 {
9426 // Copy everything *EXCEPT* the tile, misc, cset, frames, speed, delay and ltm.
9427 28410 word tile = item->tile;
9428 28410 byte miscs = item->misc_flags, cset = item->csets, frames = item->frames, speed = item->speed, delay = item->delay;
9429 28410 int32_t ltm = item->ltm;
9430
9431 28410 memcpy(item,&default_items[id],sizeof(itemdata));
9432 28410 item->tile = tile;
9433 28410 item->misc_flags = miscs;
9434 28410 item->csets = cset;
9435 28410 item->frames = frames;
9436 28410 item->speed = speed;
9437 28410 item->delay = delay;
9438 28410 item->ltm = ltm;
9439 28410 }
9440 50445 }
9441
9442 8192 void reset_itemname(int32_t id)
9443 {
9444 8192 sprintf(item_string[id],"zz%03d",id);
9445
9446
2/2
✓ Branch 0 taken 3616 times.
✓ Branch 1 taken 4576 times.
8192 if(id < iLast)
9447 4576 strcpy(item_string[id],old_item_string[id]);
9448 8192 }
9449
9450 99 int32_t readweapons(PACKFILE *f, zquestheader *Header, bool keepdata)
9451 {
9452 99 word weapons_to_read=MAXWPNS;
9453 int32_t dummy;
9454 byte padding;
9455 wpndata tempweapon;
9456 99 word s_version=0, s_cversion=0;
9457
9458
9459
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(Header->zelda_version < 0x186)
9460 {
9461 weapons_to_read=64;
9462 }
9463
9464
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(Header->zelda_version < 0x185)
9465 {
9466 weapons_to_read=32;
9467 }
9468
9469
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(Header->zelda_version > 0x192)
9470 {
9471 99 weapons_to_read=0;
9472
9473 //section version info
9474
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&s_version,f,true))
9475 {
9476 return qe_invalid;
9477 }
9478
9479 99 FFCore.quest_format[vWeaponSprites] = s_version;
9480
9481 //al_trace("Weapons version %d\n", s_version);
9482
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&s_cversion,f,true))
9483 {
9484 return qe_invalid;
9485 }
9486
9487 //section size
9488
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetl(&dummy,f,true))
9489 {
9490 return qe_invalid;
9491 }
9492
9493 //finally... section data
9494
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&weapons_to_read,f,true))
9495 {
9496 return qe_invalid;
9497 }
9498 99 }
9499
9500
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version>2)
9501 {
9502
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 96 times.
24672 for(int32_t i=0; i<weapons_to_read; i++)
9503 {
9504 char tempname[64];
9505
9506
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!pfread(tempname, 64, f, keepdata))
9507 {
9508 return qe_invalid;
9509 }
9510
9511
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24576 times.
24576 if(keepdata)
9512 {
9513 24576 strcpy(weapon_string[i], tempname);
9514 24576 }
9515 24576 }
9516
9517
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(s_version<4)
9518 {
9519 if(keepdata)
9520 {
9521 strcpy(weapon_string[iwHover],old_weapon_string[iwHover]);
9522 strcpy(weapon_string[wFIREMAGIC],old_weapon_string[wFIREMAGIC]);
9523 }
9524 }
9525
9526
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(s_version<5)
9527 {
9528 if(keepdata)
9529 {
9530 strcpy(weapon_string[iwQuarterHearts],old_weapon_string[iwQuarterHearts]);
9531 }
9532 }
9533
9534 /*
9535 if (s_version<6)
9536 {
9537 strcpy(weapon_string[iwSideRaft],old_weapon_string[iwSideRaft]);
9538 strcpy(weapon_string[iwSideLadder],old_weapon_string[iwSideLadder]);
9539 }
9540 */
9541 96 }
9542 else
9543 {
9544
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(keepdata)
9545
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 3 times.
771 for(int32_t i=0; i<WPNCNT; i++)
9546 771 reset_weaponname(i);
9547 }
9548
9549
2/2
✓ Branch 0 taken 24780 times.
✓ Branch 1 taken 99 times.
24879 for(int32_t i=0; i<weapons_to_read; i++)
9550 {
9551 24780 word oldtile = 0;
9552
2/2
✓ Branch 0 taken 3840 times.
✓ Branch 1 taken 20940 times.
24780 if (s_version < 8)
9553 {
9554
1/2
✓ Branch 0 taken 20940 times.
✗ Branch 1 not taken.
20940 if (!p_igetw(&oldtile, f, true))
9555 return qe_invalid;
9556 20940 }
9557
9558
1/2
✓ Branch 0 taken 24780 times.
✗ Branch 1 not taken.
24780 if(!p_getc(&tempweapon.misc,f,true))
9559 {
9560 return qe_invalid;
9561 }
9562
9563
1/2
✓ Branch 0 taken 24780 times.
✗ Branch 1 not taken.
24780 if(!p_getc(&tempweapon.csets,f,true))
9564 {
9565 return qe_invalid;
9566 }
9567
9568
1/2
✓ Branch 0 taken 24780 times.
✗ Branch 1 not taken.
24780 if(!p_getc(&tempweapon.frames,f,true))
9569 {
9570 return qe_invalid;
9571 }
9572
9573
1/2
✓ Branch 0 taken 24780 times.
✗ Branch 1 not taken.
24780 if(!p_getc(&tempweapon.speed,f,true))
9574 {
9575 return qe_invalid;
9576 }
9577
9578
1/2
✓ Branch 0 taken 24780 times.
✗ Branch 1 not taken.
24780 if(!p_getc(&tempweapon.type,f,true))
9579 {
9580 return qe_invalid;
9581 }
9582
9583
2/2
✓ Branch 0 taken 19148 times.
✓ Branch 1 taken 5632 times.
24780 if ( s_version >= 7 )
9584 {
9585
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetw(&tempweapon.script,f,true))
9586 {
9587 return qe_invalid;
9588 }
9589
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempweapon.tile,f,true))
9590 {
9591 return qe_invalid;
9592 }
9593 5632 }
9594
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 19148 times.
24780 if ( s_version < 7 )
9595 {
9596 19148 tempweapon.tile = oldtile;
9597 19148 }
9598
9599
1/2
✓ Branch 0 taken 24780 times.
✗ Branch 1 not taken.
24780 if(Header->zelda_version < 0x193)
9600 {
9601 if(!p_getc(&padding,f,true))
9602 {
9603 return qe_invalid;
9604 }
9605 }
9606
9607
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 204 times.
24780 if(s_version < 6)
9608 {
9609
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 204 times.
204 if(i==ewFIRETRAIL)
9610 {
9611 tempweapon.misc |= WF_BEHIND;
9612 }
9613 else
9614 204 tempweapon.misc &= ~WF_BEHIND;
9615 204 }
9616
9617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24780 times.
24780 if(keepdata==true)
9618 {
9619 24780 memcpy(&wpnsbuf[i], &tempweapon, sizeof(tempweapon));
9620 24780 }
9621 24780 }
9622
9623
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata==true)
9624 {
9625
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version<2)
9626 {
9627 3 wpnsbuf[wSBOOM]=wpnsbuf[wBOOM];
9628 3 }
9629
9630
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version<5)
9631 {
9632 3 wpnsbuf[iwQuarterHearts].tile=1;
9633 3 wpnsbuf[iwQuarterHearts].csets=1;
9634 3 }
9635
9636
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(Header->zelda_version < 0x176)
9637 {
9638 wpnsbuf[iwSpawn] = *((wpndata*)(itemsbuf + iMisc1));
9639 wpnsbuf[iwDeath] = *((wpndata*)(itemsbuf + iMisc2));
9640 memset(&itemsbuf[iMisc1],0,sizeof(itemdata));
9641 memset(&itemsbuf[iMisc2],0,sizeof(itemdata));
9642 }
9643
9644
1/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
99 if((Header->zelda_version < 0x192)||
9645
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ((Header->zelda_version == 0x192)&&(Header->build<129)))
9646 {
9647 wpnsbuf[wHSCHAIN_V] = wpnsbuf[wHSCHAIN_H];
9648 }
9649
9650
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if((Header->zelda_version < 0x210))
9651 {
9652 wpnsbuf[wLSHEAD] = wpnsbuf[wHSHEAD];
9653 wpnsbuf[wLSCHAIN_H] = wpnsbuf[wHSCHAIN_H];
9654 wpnsbuf[wLSHANDLE] = wpnsbuf[wHSHANDLE];
9655 wpnsbuf[wLSCHAIN_V] = wpnsbuf[wHSCHAIN_V];
9656 }
9657 99 }
9658
9659 99 return 0;
9660 99 }
9661
9662 99 void init_guys(int32_t guyversion)
9663 {
9664
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 99 times.
50787 for(int32_t i=0; i<MAXGUYS; i++)
9665 {
9666 50688 guysbuf[i] = default_guys[0];
9667 50688 }
9668
9669
2/2
✓ Branch 0 taken 17523 times.
✓ Branch 1 taken 99 times.
17622 for(int32_t i=0; i<OLDMAXGUYS; i++)
9670 {
9671 17523 guysbuf[i] = default_guys[i];
9672
2/2
✓ Branch 0 taken 17325 times.
✓ Branch 1 taken 198 times.
17523 guysbuf[i].spr_shadow = (guysbuf[i].family==eeROCK && guysbuf[i].misc10==1) ? iwLargeShadow : iwShadow;
9673 17523 guysbuf[i].spr_death = iwDeath;
9674 17523 guysbuf[i].spr_spawn = iwSpawn;
9675 // Patra fix: 2.10 BSPatras used spDIG. 2.50 Patras use CSet 7.
9676
4/4
✓ Branch 0 taken 531 times.
✓ Branch 1 taken 16992 times.
✓ Branch 2 taken 528 times.
✓ Branch 3 taken 3 times.
17523 if(guyversion<=3 && i==ePATRABS)
9677 {
9678 3 guysbuf[i].bosspal=spDIG;
9679 3 guysbuf[i].cset=14;
9680 3 guysbuf[i].misc9=14;
9681 3 }
9682
9683
2/2
✓ Branch 0 taken 16992 times.
✓ Branch 1 taken 531 times.
17523 if(guyversion<=3)
9684 {
9685 // Rope/Ghini Flash rules
9686
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 531 times.
531 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
9687 {
9688
2/2
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 3 times.
531 if(i==eROPE2)
9689 {
9690 3 guysbuf[i].flags2 &= ~guy_flashing;
9691 3 }
9692 531 }
9693
9694
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 531 times.
531 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
9695 {
9696
12/12
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 525 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 522 times.
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 519 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 516 times.
✓ Branch 9 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 11 taken 513 times.
531 if(i==eBUBBLEST || i==eBUBBLESP || i==eBUBBLESR || i==eBUBBLEIT || i==eBUBBLEIP || i==eBUBBLEIR)
9697 {
9698 18 guysbuf[i].flags2 &= ~guy_flashing;
9699 18 }
9700 531 }
9701
9702
2/2
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 3 times.
531 if(i==eGHINI2)
9703 {
9704
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
9705 {
9706 3 guysbuf[i].flags2 |= guy_blinking;
9707 3 }
9708
9709
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
9710 {
9711 guysbuf[i].flags2 |= guy_transparent;
9712 }
9713 3 }
9714 531 }
9715
9716 // Darknut fix
9717
10/10
✓ Branch 0 taken 17424 times.
✓ Branch 1 taken 99 times.
✓ Branch 2 taken 17325 times.
✓ Branch 3 taken 99 times.
✓ Branch 4 taken 17226 times.
✓ Branch 5 taken 99 times.
✓ Branch 6 taken 17127 times.
✓ Branch 7 taken 99 times.
✓ Branch 8 taken 99 times.
✓ Branch 9 taken 17028 times.
17523 if(i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)
9718 {
9719
2/2
✓ Branch 0 taken 315 times.
✓ Branch 1 taken 180 times.
495 if(get_bit(quest_rules,qr_NEWENEMYTILES))
9720 {
9721 315 guysbuf[i].s_tile=guysbuf[i].e_tile+120;
9722 315 guysbuf[i].s_width=guysbuf[i].e_width;
9723 315 guysbuf[i].s_height=guysbuf[i].e_height;
9724 315 }
9725 180 else guysbuf[i].s_tile=860;
9726
9727
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 15 times.
495 if(get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
9728 {
9729 15 guysbuf[i].flags |= guy_bkshield;
9730 15 }
9731 495 }
9732
9733
3/4
✓ Branch 0 taken 17424 times.
✓ Branch 1 taken 99 times.
✓ Branch 2 taken 17523 times.
✗ Branch 3 not taken.
17523 if((i==eGELTRIB || i==eFGELTRIB) && get_bit(deprecated_rules,qr_OLDTRIBBLES_DEP))
9734 {
9735 guysbuf[i].misc3 = (i==eFGELTRIB ? eFZOL : eZOL);
9736 }
9737 17523 }
9738 99 }
9739
9740 768 void reset_weaponname(int32_t i)
9741 {
9742
2/2
✓ Branch 0 taken 264 times.
✓ Branch 1 taken 504 times.
768 if(i<wLast)
9743 {
9744 264 strcpy(weapon_string[i],old_weapon_string[i]);
9745 264 }
9746 else
9747 504 sprintf(weapon_string[i],"zz%03d",i);
9748 768 }
9749
9750 99 void init_item_drop_sets()
9751 {
9752
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
9753 {
9754 // item_drop_sets[i] = default_item_drop_sets[0];
9755 25344 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
9756 25344 }
9757
9758
2/2
✓ Branch 0 taken 1287 times.
✓ Branch 1 taken 99 times.
1386 for(int32_t i=0; i<isMAX; i++)
9759 {
9760 1287 item_drop_sets[i] = default_item_drop_sets[i];
9761
9762 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
9763
2/2
✓ Branch 0 taken 12870 times.
✓ Branch 1 taken 1287 times.
14157 for(int32_t j=0; j<10; ++j)
9764 {
9765 12870 int32_t it = item_drop_sets[i].item[j];
9766
9767
3/4
✓ Branch 0 taken 9108 times.
✓ Branch 1 taken 3762 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 588 times.
12870 if((itemsbuf[it].family == itype_rupee && ((itemsbuf[it].amount)&0xFFF) == 10)
9768
2/2
✓ Branch 0 taken 588 times.
✓ Branch 1 taken 8520 times.
9108 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
9769 {
9770 588 item_drop_sets[i].chance[j+1]=0;
9771 588 }
9772
3/4
✓ Branch 0 taken 396 times.
✓ Branch 1 taken 11886 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 396 times.
12282 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
9773 {
9774 item_drop_sets[i].chance[j+1]=0;
9775 }
9776
9777 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
9778
2/2
✓ Branch 0 taken 12862 times.
✓ Branch 1 taken 8 times.
12870 if(itemsbuf[it].family == itype_misc)
9779 {
9780 // If a non-gameplay item was selected, then item drop was aborted.
9781 // Reflect this by increasing the 'Nothing' chance accordingly.
9782 8 item_drop_sets[i].chance[0]+=item_drop_sets[i].chance[j+1];
9783 8 item_drop_sets[i].chance[j+1]=0;
9784 8 }
9785 12870 }
9786 1287 }
9787 99 }
9788
9789 99 void init_favorites()
9790 {
9791
2/2
✓ Branch 0 taken 19800 times.
✓ Branch 1 taken 99 times.
19899 for(int32_t i=0; i<MAXFAVORITECOMBOS; i++)
9792 {
9793 19800 favorite_combos[i]=-1;
9794 19800 }
9795
9796
2/2
✓ Branch 0 taken 19800 times.
✓ Branch 1 taken 99 times.
19899 for(int32_t i=0; i<MAXFAVORITECOMBOALIASES; i++)
9797 {
9798 19800 favorite_comboaliases[i]=-1;
9799 19800 }
9800 99 }
9801
9802 const char *ctype_name[cMAX]=
9803 {
9804 "cNONE", "cSTAIR", "cCAVE", "cWATER", "cARMOS", "cGRAVE", "cDOCK",
9805 "cUNDEF", "cPUSH_WAIT", "cPUSH_HEAVY", "cPUSH_HW", "cL_STATUE", "cR_STATUE",
9806 "cWALKSLOW", "cCVUP", "cCVDOWN", "cCVLEFT", "cCVRIGHT", "cSWIMWARP", "cDIVEWARP",
9807 "cLADDERHOOKSHOT", "cTRIGNOFLAG", "cTRIGFLAG", "cZELDA", "cSLASH", "cSLASHITEM",
9808 "cPUSH_HEAVY2", "cPUSH_HW2", "cPOUND", "cHSGRAB", "cHSBRIDGE", "cDAMAGE1",
9809 "cDAMAGE2", "cDAMAGE3", "cDAMAGE4", "cC_STATUE", "cTRAP_H", "cTRAP_V", "cTRAP_4",
9810 "cTRAP_LR", "cTRAP_UD", "cPIT", "cHOOKSHOTONLY", "cOVERHEAD", "cNOFLYZONE", "cMIRROR",
9811 "cMIRRORSLASH", "cMIRRORBACKSLASH", "cMAGICPRISM", "cMAGICPRISM4",
9812 "cMAGICSPONGE", "cCAVE2", "cEYEBALL_A", "cEYEBALL_B", "cNOJUMPZONE", "cBUSH",
9813 "cFLOWERS", "cTALLGRASS", "cSHALLOWWATER", "cLOCKBLOCK", "cLOCKBLOCK2",
9814 "cBOSSLOCKBLOCK", "cBOSSLOCKBLOCK2", "cLADDERONLY", "cBSGRAVE",
9815 "cCHEST", "cCHEST2", "cLOCKEDCHEST", "cLOCKEDCHEST2", "cBOSSCHEST", "cBOSSCHEST2",
9816 "cRESET", "cSAVE", "cSAVE2", "cCAVEB", "cCAVEC", "cCAVED",
9817 "cSTAIRB", "cSTAIRC", "cSTAIRD", "cPITB", "cPITC", "cPITD",
9818 "cCAVE2B", "cCAVE2C", "cCAVE2D", "cSWIMWARPB", "cSWIMWARPC", "cSWIMWARPD",
9819 "cDIVEWARPB", "cDIVEWARPC", "cDIVEWARPD", "cSTAIRR", "cPITR",
9820 "cAWARPA", "cAWARPB", "cAWARPC", "cAWARPD", "cAWARPR",
9821 "cSWARPA", "cSWARPB", "cSWARPC", "cSWARPD", "cSWARPR", "cSTRIGNOFLAG", "cSTRIGFLAG",
9822 "cSTEP", "cSTEPSAME", "cSTEPALL", "cSTEPCOPY", "cNOENEMY", "cBLOCKARROW1", "cBLOCKARROW2",
9823 "cBLOCKARROW3", "cBLOCKBRANG1", "cBLOCKBRANG2", "cBLOCKBRANG3", "cBLOCKSBEAM", "cBLOCKALL",
9824 "cBLOCKFIREBALL", "cDAMAGE5", "cDAMAGE6", "cDAMAGE7", "cCHANGE", "cSPINTILE1", "cSPINTILE2",
9825 "cSCREENFREEZE", "cSCREENFREEZEFF", "cNOGROUNDENEMY", "cSLASHNEXT", "cSLASHNEXTITEM", "cBUSHNEXT"
9826 "cSLASHTOUCHY", "cSLASHITEMTOUCHY", "cBUSHTOUCHY", "cFLOWERSTOUCHY", "cTALLGRASSTOUCHY",
9827 "cSLASHNEXTTOUCHY", "cSLASHNEXTITEMTOUCHY", "cBUSHNEXTTOUCHY", "cEYEBALL_4", "cTALLGRASSNEXT",
9828 "cSCRIPT1", "cSCRIPT2", "cSCRIPT3", "cSCRIPT4", "cSCRIPT5",
9829 "cSCRIPT6", "cSCRIPT7", "cSCRIPT8", "cSCRIPT9", "cSCRIPT10",
9830 "cSCRIPT11", "cSCRIPT12", "cSCRIPT13", "cSCRIPT14", "cSCRIPT15",
9831 "cSCRIPT16", "cSCRIPT17", "cSCRIPT18", "cSCRIPT19", "cSCRIPT20"
9832
9833 };
9834
9835 178 int32_t init_combo_classes()
9836 {
9837
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 178 times.
178 zinfo* zi = (load_tmp_zi ? load_tmp_zi : &ZI);
9838
2/2
✓ Branch 0 taken 31684 times.
✓ Branch 1 taken 178 times.
31862 for(int32_t i=0; i<cMAX; i++)
9839 {
9840 31684 combo_class_buf[i] = default_combo_classes[i];
9841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31684 times.
31684 if ( char const* nm = zi->getComboTypeName(i) )
9842 {
9843 31684 size_t len = strlen(nm);
9844
2/2
✓ Branch 0 taken 2027776 times.
✓ Branch 1 taken 31684 times.
2059460 for ( size_t q = 0; q < 64; q++ )
9845 {
9846
2/2
✓ Branch 0 taken 469208 times.
✓ Branch 1 taken 1558568 times.
2027776 combo_class_buf[i].name[q] = (q<len ? nm[q] : 0);
9847 2027776 }
9848 31684 }
9849 31684 }
9850
9851 178 return 0;
9852 }
9853
9854 77 int32_t readherosprites2(PACKFILE *f, int32_t v_herosprites, int32_t cv_herosprites, bool keepdata)
9855 {
9856
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 assert(v_herosprites < 6);
9857 //these are here to bypass compiler warnings about unused arguments
9858 77 cv_herosprites=cv_herosprites;
9859
9860
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(keepdata)
9861 {
9862 77 zinit.hero_swim_speed=67; //default
9863 77 setupherotiles(zinit.heroAnimationStyle);
9864 77 setupherodefenses();
9865 77 setupherooffsets();
9866 77 }
9867
9868
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 74 times.
77 if(v_herosprites>=0)
9869 {
9870 word tile, tile2;
9871 byte flip, extend, dummy_byte;
9872
9873
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 74 times.
370 for(int32_t i=0; i<4; i++)
9874 {
9875
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_igetw(&tile,f,keepdata))
9876 {
9877 return qe_invalid;
9878 }
9879
9880
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&flip,f,keepdata))
9881 {
9882 return qe_invalid;
9883 }
9884
9885
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&extend,f,keepdata))
9886 {
9887 return qe_invalid;
9888 }
9889
9890
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 296 times.
296 if(keepdata)
9891 {
9892 296 walkspr[i][spr_tile]=(int32_t)tile;
9893 296 walkspr[i][spr_flip]=(int32_t)flip;
9894 296 walkspr[i][spr_extend]=(int32_t)extend;
9895 296 }
9896 296 }
9897
9898
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 74 times.
370 for(int32_t i=0; i<4; i++)
9899 {
9900
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_igetw(&tile,f,keepdata))
9901 {
9902 return qe_invalid;
9903 }
9904
9905
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&flip,f,keepdata))
9906 {
9907 return qe_invalid;
9908 }
9909
9910
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&extend,f,keepdata))
9911 {
9912 return qe_invalid;
9913 }
9914
9915
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 296 times.
296 if(keepdata)
9916 {
9917 296 stabspr[i][spr_tile]=(int32_t)tile;
9918 296 stabspr[i][spr_flip]=(int32_t)flip;
9919 296 stabspr[i][spr_extend]=(int32_t)extend;
9920 296 }
9921 296 }
9922
9923
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 74 times.
370 for(int32_t i=0; i<4; i++)
9924 {
9925
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_igetw(&tile,f,keepdata))
9926 {
9927 return qe_invalid;
9928 }
9929
9930
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&flip,f,keepdata))
9931 {
9932 return qe_invalid;
9933 }
9934
9935
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&extend,f,keepdata))
9936 {
9937 return qe_invalid;
9938 }
9939
9940
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 296 times.
296 if(keepdata)
9941 {
9942 296 slashspr[i][spr_tile]=(int32_t)tile;
9943 296 slashspr[i][spr_flip]=(int32_t)flip;
9944 296 slashspr[i][spr_extend]=(int32_t)extend;
9945 296 }
9946 296 }
9947
9948
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 74 times.
370 for(int32_t i=0; i<4; i++)
9949 {
9950
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_igetw(&tile,f,keepdata))
9951 {
9952 return qe_invalid;
9953 }
9954
9955
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&flip,f,keepdata))
9956 {
9957 return qe_invalid;
9958 }
9959
9960
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&extend,f,keepdata))
9961 {
9962 return qe_invalid;
9963 }
9964
9965
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 296 times.
296 if(keepdata)
9966 {
9967 296 floatspr[i][spr_tile]=(int32_t)tile;
9968 296 floatspr[i][spr_flip]=(int32_t)flip;
9969 296 floatspr[i][spr_extend]=(int32_t)extend;
9970 296 }
9971 296 }
9972
9973
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if(v_herosprites>1)
9974 {
9975
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 74 times.
370 for(int32_t i=0; i<4; i++)
9976 {
9977
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_igetw(&tile,f,keepdata))
9978 {
9979 return qe_invalid;
9980 }
9981
9982
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&flip,f,keepdata))
9983 {
9984 return qe_invalid;
9985 }
9986
9987
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&extend,f,keepdata))
9988 {
9989 return qe_invalid;
9990 }
9991
9992
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 296 times.
296 if(keepdata)
9993 {
9994 296 swimspr[i][spr_tile]=(int32_t)tile;
9995 296 swimspr[i][spr_flip]=(int32_t)flip;
9996 296 swimspr[i][spr_extend]=(int32_t)extend;
9997 296 }
9998 296 }
9999 74 }
10000
10001
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 74 times.
370 for(int32_t i=0; i<4; i++)
10002 {
10003
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_igetw(&tile,f,keepdata))
10004 {
10005 return qe_invalid;
10006 }
10007
10008
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&flip,f,keepdata))
10009 {
10010 return qe_invalid;
10011 }
10012
10013
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&extend,f,keepdata))
10014 {
10015 return qe_invalid;
10016 }
10017
10018
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 296 times.
296 if(keepdata)
10019 {
10020 296 divespr[i][spr_tile]=(int32_t)tile;
10021 296 divespr[i][spr_flip]=(int32_t)flip;
10022 296 divespr[i][spr_extend]=(int32_t)extend;
10023 296 }
10024 296 }
10025
10026
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 74 times.
370 for(int32_t i=0; i<4; i++)
10027 {
10028
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_igetw(&tile,f,keepdata))
10029 {
10030 return qe_invalid;
10031 }
10032
10033
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&flip,f,keepdata))
10034 {
10035 return qe_invalid;
10036 }
10037
10038
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&extend,f,keepdata))
10039 {
10040 return qe_invalid;
10041 }
10042
10043
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 296 times.
296 if(keepdata)
10044 {
10045 296 poundspr[i][spr_tile]=(int32_t)tile;
10046 296 poundspr[i][spr_flip]=(int32_t)flip;
10047 296 poundspr[i][spr_extend]=(int32_t)extend;
10048 296 }
10049 296 }
10050
10051
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 if(!p_igetw(&tile,f,keepdata))
10052 {
10053 return qe_invalid;
10054 }
10055
10056 74 flip=0;
10057
10058
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if(v_herosprites>0)
10059 {
10060
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 if(!p_getc(&flip,f,keepdata))
10061 {
10062 return qe_invalid;
10063 }
10064 74 }
10065
10066
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 if(!p_getc(&extend,f,keepdata))
10067 {
10068 return qe_invalid;
10069 }
10070
10071
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if(keepdata)
10072 {
10073 74 castingspr[spr_tile]=(int32_t)tile;
10074 74 castingspr[spr_flip]=(int32_t)flip;
10075 74 castingspr[spr_extend]=(int32_t)extend;
10076 74 }
10077
10078
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 if(v_herosprites>0)
10079 {
10080 74 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10081
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 74 times.
222 for(int32_t i=0; i<2; i++)
10082 {
10083
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 148 times.
444 for(int32_t j=0; j<num_holdsprs; j++)
10084 {
10085
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_igetw(&tile,f,keepdata))
10086 {
10087 return qe_invalid;
10088 }
10089
10090
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&flip,f,keepdata))
10091 {
10092 return qe_invalid;
10093 }
10094
10095
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&extend,f,keepdata))
10096 {
10097 return qe_invalid;
10098 }
10099
10100
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 296 times.
296 if(keepdata)
10101 {
10102 296 holdspr[i][j][spr_tile]=(int32_t)tile;
10103 296 holdspr[i][j][spr_flip]=(int32_t)flip;
10104 296 holdspr[i][j][spr_extend]=(int32_t)extend;
10105 296 }
10106 296 }
10107 148 }
10108 74 }
10109 else
10110 {
10111 for(int32_t i=0; i<2; i++)
10112 {
10113 if(!p_igetw(&tile,f,keepdata))
10114 {
10115 return qe_invalid;
10116 }
10117
10118 if(!p_igetw(&tile2,f,keepdata))
10119 {
10120 return qe_invalid;
10121 }
10122
10123 if(!p_getc(&extend,f,keepdata))
10124 {
10125 return qe_invalid;
10126 }
10127
10128 if(keepdata)
10129 {
10130 holdspr[i][spr_hold1][spr_tile]=(int32_t)tile;
10131 holdspr[i][spr_hold1][spr_flip]=(int32_t)flip;
10132 holdspr[i][spr_hold1][spr_extend]=(int32_t)extend;
10133 holdspr[i][spr_hold2][spr_tile]=(int32_t)tile2;
10134 holdspr[i][spr_hold2][spr_flip]=(int32_t)flip;
10135 holdspr[i][spr_hold2][spr_extend]=(int32_t)extend;
10136 }
10137 }
10138 }
10139
10140
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if(v_herosprites>2)
10141 {
10142
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 74 times.
370 for(int32_t i=0; i<4; i++)
10143 {
10144
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_igetw(&tile,f,keepdata))
10145 {
10146 return qe_invalid;
10147 }
10148
10149
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&flip,f,keepdata))
10150 {
10151 return qe_invalid;
10152 }
10153
10154
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&extend,f,keepdata))
10155 {
10156 return qe_invalid;
10157 }
10158
10159
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 296 times.
296 if(keepdata)
10160 {
10161 296 jumpspr[i][spr_tile]=(int32_t)tile;
10162 296 jumpspr[i][spr_flip]=(int32_t)flip;
10163 296 jumpspr[i][spr_extend]=(int32_t)extend;
10164 296 }
10165 296 }
10166 74 }
10167
10168
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if(v_herosprites>3)
10169 {
10170
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 74 times.
370 for(int32_t i=0; i<4; i++)
10171 {
10172
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_igetw(&tile,f,keepdata))
10173 {
10174 return qe_invalid;
10175 }
10176
10177
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&flip,f,keepdata))
10178 {
10179 return qe_invalid;
10180 }
10181
10182
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&extend,f,keepdata))
10183 {
10184 return qe_invalid;
10185 }
10186
10187
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 296 times.
296 if(keepdata)
10188 {
10189 296 chargespr[i][spr_tile]=(int32_t)tile;
10190 296 chargespr[i][spr_flip]=(int32_t)flip;
10191 296 chargespr[i][spr_extend]=(int32_t)extend;
10192 296 }
10193 296 }
10194 74 }
10195
10196
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if(v_herosprites>4)
10197 {
10198
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if(!p_getc(&dummy_byte,f,keepdata))
10199 {
10200 return qe_invalid;
10201 }
10202
10203
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if(keepdata)
10204 {
10205 74 zinit.hero_swim_speed=(byte)dummy_byte;
10206 74 }
10207 74 }
10208
10209
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 if(keepdata)
10210 {
10211 74 memset(frozenspr, 0, sizeof(frozenspr));
10212 74 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
10213 74 memset(onfirespr, 0, sizeof(onfirespr));
10214 74 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
10215 74 memset(diggingspr, 0, sizeof(diggingspr));
10216 74 memset(usingrodspr, 0, sizeof(usingrodspr));
10217 74 memset(usingcanespr, 0, sizeof(usingcanespr));
10218 74 memset(pushingspr, 0, sizeof(pushingspr));
10219 74 memset(liftingspr, 0, sizeof(liftingspr));
10220 74 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
10221 74 memset(stunnedspr, 0, sizeof(stunnedspr));
10222 74 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
10223 74 memset(fallingspr, 0, sizeof(fallingspr));
10224 74 memset(shockedspr, 0, sizeof(shockedspr));
10225 74 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
10226 74 memset(pullswordspr, 0, sizeof(pullswordspr));
10227 74 memset(readingspr, 0, sizeof(readingspr));
10228 74 memset(slash180spr, 0, sizeof(slash180spr));
10229 74 memset(slashZ4spr, 0, sizeof(slashZ4spr));
10230 74 memset(dashspr, 0, sizeof(dashspr));
10231 74 memset(bonkspr, 0, sizeof(bonkspr));
10232 74 memset(medallionsprs, 0, sizeof(medallionsprs));
10233 74 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
10234 74 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
10235
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 74 times.
370 for(int32_t q = 0; q < 4; ++q)
10236 {
10237
2/2
✓ Branch 0 taken 888 times.
✓ Branch 1 taken 296 times.
1184 for(int32_t p = 0; p < 3; ++p)
10238 {
10239 888 drowningspr[q][p] = divespr[q][p];
10240 888 drowning_lavaspr[q][p] = divespr[q][p];
10241 888 }
10242 296 }
10243 74 memset(sideswimspr, 0, sizeof(sideswimspr));
10244 74 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
10245 74 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
10246 74 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
10247 74 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
10248 74 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
10249 74 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
10250 74 }
10251 74 }
10252
10253 77 return 0;
10254 77 }
10255
10256 3740 void setSprite(int32_t* arr, int32_t tile, int32_t flip, int32_t ext)
10257 {
10258 3740 arr[spr_tile] = tile;
10259
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3740 times.
3740 arr[spr_flip] = (flip > 3 ? 0 : flip);
10260
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3740 times.
3740 arr[spr_extend] = (ext > 2 ? 0 : ext);
10261 3740 }
10262 //Used to read the player sprites as int32_t, not word.
10263 22 int32_t readherosprites3(PACKFILE *f, int32_t v_herosprites, int32_t cv_herosprites, bool keepdata)
10264 {
10265 //these are here to bypass compiler warnings about unused arguments
10266 22 cv_herosprites=cv_herosprites;
10267
10268
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if(keepdata)
10269 {
10270 22 zinit.hero_swim_speed=67; //default
10271 22 setupherotiles(zinit.heroAnimationStyle);
10272 22 setupherodefenses();
10273 22 setupherooffsets();
10274 22 }
10275
10276 int32_t tile, tile2;
10277 byte flip, extend, dummy_byte;
10278
10279
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if(v_herosprites>=0)
10280 {
10281
10282
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t i=0; i<4; i++)
10283 {
10284
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10285 {
10286 return qe_invalid;
10287 }
10288
10289
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
10290 {
10291 return qe_invalid;
10292 }
10293
10294
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
10295 {
10296 return qe_invalid;
10297 }
10298
10299 88 if(keepdata)
10300 {
10301 88 setSprite(walkspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10302 88 }
10303 88 }
10304
10305
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t i=0; i<4; i++)
10306 {
10307
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10308 {
10309 return qe_invalid;
10310 }
10311
10312
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
10313 {
10314 return qe_invalid;
10315 }
10316
10317
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
10318 {
10319 return qe_invalid;
10320 }
10321
10322
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10323 {
10324 88 setSprite(stabspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10325 88 }
10326 88 }
10327
10328
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t i=0; i<4; i++)
10329 {
10330
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10331 {
10332 return qe_invalid;
10333 }
10334
10335
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
10336 {
10337 return qe_invalid;
10338 }
10339
10340
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
10341 {
10342 return qe_invalid;
10343 }
10344
10345
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10346 {
10347 88 setSprite(slashspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10348 88 }
10349 88 }
10350
10351
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t i=0; i<4; i++)
10352 {
10353
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10354 {
10355 return qe_invalid;
10356 }
10357
10358
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
10359 {
10360 return qe_invalid;
10361 }
10362
10363
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
10364 {
10365 return qe_invalid;
10366 }
10367
10368
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10369 {
10370 88 setSprite(floatspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10371 88 }
10372 88 }
10373
10374
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if(v_herosprites>1)
10375 {
10376
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t i=0; i<4; i++)
10377 {
10378
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10379 {
10380 return qe_invalid;
10381 }
10382
10383
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
10384 {
10385 return qe_invalid;
10386 }
10387
10388
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
10389 {
10390 return qe_invalid;
10391 }
10392
10393
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10394 {
10395 88 setSprite(swimspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10396 88 }
10397 88 }
10398 22 }
10399
10400
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t i=0; i<4; i++)
10401 {
10402
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10403 {
10404 return qe_invalid;
10405 }
10406
10407
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
10408 {
10409 return qe_invalid;
10410 }
10411
10412
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
10413 {
10414 return qe_invalid;
10415 }
10416
10417
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10418 {
10419 88 setSprite(divespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10420 88 }
10421 88 }
10422
10423
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t i=0; i<4; i++)
10424 {
10425
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10426 {
10427 return qe_invalid;
10428 }
10429
10430
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
10431 {
10432 return qe_invalid;
10433 }
10434
10435
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
10436 {
10437 return qe_invalid;
10438 }
10439
10440
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10441 {
10442 88 setSprite(poundspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10443 88 }
10444 88 }
10445
10446
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(!p_igetl(&tile,f,keepdata))
10447 {
10448 return qe_invalid;
10449 }
10450
10451 22 flip=0;
10452
10453
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if(v_herosprites>0)
10454 {
10455
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(!p_getc(&flip,f,keepdata))
10456 {
10457 return qe_invalid;
10458 }
10459 22 }
10460
10461
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(!p_getc(&extend,f,keepdata))
10462 {
10463 return qe_invalid;
10464 }
10465
10466
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if(keepdata)
10467 {
10468 22 setSprite(castingspr, int32_t(tile), int32_t(flip), int32_t(extend));
10469 22 }
10470
10471
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(v_herosprites>0)
10472 {
10473 22 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10474
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 22 times.
66 for(int32_t i=0; i<2; i++)
10475 {
10476
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 44 times.
176 for(int32_t j=0; j<num_holdsprs; j++)
10477 {
10478
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(!p_igetl(&tile,f,keepdata))
10479 {
10480 return qe_invalid;
10481 }
10482
10483
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
132 if(!p_getc(&flip,f,keepdata))
10484 {
10485 return qe_invalid;
10486 }
10487
10488
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
132 if(!p_getc(&extend,f,keepdata))
10489 {
10490 return qe_invalid;
10491 }
10492
10493
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
132 if(keepdata)
10494 {
10495 132 setSprite(holdspr[i][j], int32_t(tile), int32_t(flip), int32_t(extend));
10496 132 }
10497 132 }
10498 44 }
10499 22 }
10500 else
10501 {
10502 for(int32_t i=0; i<2; i++)
10503 {
10504 if(!p_igetl(&tile,f,keepdata))
10505 {
10506 return qe_invalid;
10507 }
10508
10509 if(!p_igetl(&tile2,f,keepdata))
10510 {
10511 return qe_invalid;
10512 }
10513
10514 if(!p_getc(&extend,f,keepdata))
10515 {
10516 return qe_invalid;
10517 }
10518
10519 if(keepdata)
10520 {
10521 setSprite(holdspr[i][spr_hold1], int32_t(tile), int32_t(flip), int32_t(extend));
10522 setSprite(holdspr[i][spr_hold2], int32_t(tile2), int32_t(flip), int32_t(extend));
10523 }
10524 }
10525 }
10526
10527
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if(v_herosprites>2)
10528 {
10529
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t i=0; i<4; i++)
10530 {
10531
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10532 {
10533 return qe_invalid;
10534 }
10535
10536
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
10537 {
10538 return qe_invalid;
10539 }
10540
10541
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
10542 {
10543 return qe_invalid;
10544 }
10545
10546
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10547 {
10548 88 setSprite(jumpspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10549 88 }
10550 88 }
10551 22 }
10552
10553
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if(v_herosprites>3)
10554 {
10555
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t i=0; i<4; i++)
10556 {
10557
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10558 {
10559 return qe_invalid;
10560 }
10561
10562
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
10563 {
10564 return qe_invalid;
10565 }
10566
10567
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
10568 {
10569 return qe_invalid;
10570 }
10571
10572
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10573 {
10574 88 setSprite(chargespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10575 88 }
10576 88 }
10577 22 }
10578
10579
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if(v_herosprites>4)
10580 {
10581
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(!p_getc(&dummy_byte,f,keepdata))
10582 {
10583 return qe_invalid;
10584 }
10585
10586
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if(keepdata)
10587 {
10588 22 zinit.hero_swim_speed=(byte)dummy_byte;
10589 22 }
10590 22 }
10591
10592
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(v_herosprites>6)
10593 {
10594
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10595 {
10596
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10597 return qe_invalid;
10598
10599
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
10600 return qe_invalid;
10601
10602
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
10603 return qe_invalid;
10604
10605
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10606 {
10607 88 setSprite(frozenspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10608 88 }
10609 88 }
10610
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10611 {
10612
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10613 return qe_invalid;
10614
10615
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
10616 return qe_invalid;
10617
10618
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
10619 return qe_invalid;
10620
10621
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10622 {
10623 88 setSprite(frozen_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10624 88 }
10625 88 }
10626
10627
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10628 {
10629
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10630 return qe_invalid;
10631
10632
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
10633 return qe_invalid;
10634
10635
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
10636 return qe_invalid;
10637
10638
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10639 {
10640 88 setSprite(onfirespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10641 88 }
10642 88 }
10643
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10644 {
10645
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10646 return qe_invalid;
10647
10648
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
10649 return qe_invalid;
10650
10651
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
10652 return qe_invalid;
10653
10654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10655 {
10656 88 setSprite(onfire_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10657 88 }
10658 88 }
10659
10660
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10661 {
10662
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10663 return qe_invalid;
10664
10665
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
10666 return qe_invalid;
10667
10668
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
10669 return qe_invalid;
10670
10671
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10672 {
10673 88 setSprite(diggingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10674 88 }
10675 88 }
10676
10677
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10678 {
10679
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10680 return qe_invalid;
10681
10682
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&flip,f,keepdata))
10683 return qe_invalid;
10684
10685
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
10686 return qe_invalid;
10687
10688
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10689 {
10690 88 setSprite(usingrodspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10691 88 }
10692 88 }
10693
10694
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10695 {
10696
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10697 return qe_invalid;
10698
10699
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&flip,f,keepdata))
10700 return qe_invalid;
10701
10702
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&extend,f,keepdata))
10703 return qe_invalid;
10704
10705
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10706 {
10707 88 setSprite(usingcanespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10708 88 }
10709 88 }
10710
10711
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10712 {
10713
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10714 return qe_invalid;
10715
10716
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
10717 return qe_invalid;
10718
10719
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
10720 return qe_invalid;
10721
10722
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10723 {
10724 88 setSprite(pushingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10725 88 }
10726 88 }
10727
10728
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10729 {
10730
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10731 return qe_invalid;
10732
10733
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&flip,f,keepdata))
10734 return qe_invalid;
10735
10736
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&extend,f,keepdata))
10737 return qe_invalid;
10738
10739 88 byte frames = 0;
10740
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 80 times.
88 if(v_herosprites > 15)
10741 {
10742
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 if(!p_getc(&frames,f,keepdata))
10743 return qe_invalid;
10744 80 }
10745
10746
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10747 {
10748 88 setSprite(liftingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10749 88 liftingspr[q][spr_frames] = frames;
10750 88 }
10751 88 }
10752
10753
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10754 {
10755
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10756 return qe_invalid;
10757
10758
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&flip,f,keepdata))
10759 return qe_invalid;
10760
10761
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&extend,f,keepdata))
10762 return qe_invalid;
10763
10764
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10765 {
10766 88 setSprite(liftingwalkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10767 88 }
10768 88 }
10769
10770
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10771 {
10772
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_igetl(&tile,f,keepdata))
10773 return qe_invalid;
10774
10775
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&flip,f,keepdata))
10776 return qe_invalid;
10777
10778
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
10779 return qe_invalid;
10780
10781
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10782 {
10783 88 setSprite(stunnedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10784 88 }
10785 88 }
10786
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10787 {
10788
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10789 return qe_invalid;
10790
10791
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&flip,f,keepdata))
10792 return qe_invalid;
10793
10794
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&extend,f,keepdata))
10795 return qe_invalid;
10796
10797
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10798 {
10799 88 setSprite(stunned_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10800 88 }
10801 88 }
10802
10803
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10804 {
10805
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10806 return qe_invalid;
10807
10808
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&flip,f,keepdata))
10809 return qe_invalid;
10810
10811
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
10812 return qe_invalid;
10813
10814
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10815 {
10816 88 setSprite(drowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10817 88 }
10818 88 }
10819
10820
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10821 {
10822
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10823 return qe_invalid;
10824
10825
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&flip,f,keepdata))
10826 return qe_invalid;
10827
10828
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&extend,f,keepdata))
10829 return qe_invalid;
10830
10831
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10832 {
10833 88 setSprite(drowning_lavaspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10834 88 }
10835 88 }
10836
10837
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10838 {
10839
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10840 return qe_invalid;
10841
10842
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&flip,f,keepdata))
10843 return qe_invalid;
10844
10845
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&extend,f,keepdata))
10846 return qe_invalid;
10847
10848
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10849 {
10850 88 setSprite(fallingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10851 88 }
10852 88 }
10853
10854
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10855 {
10856
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10857 return qe_invalid;
10858
10859
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&flip,f,keepdata))
10860 return qe_invalid;
10861
10862
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&extend,f,keepdata))
10863 return qe_invalid;
10864
10865
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10866 {
10867 88 setSprite(shockedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10868 88 }
10869 88 }
10870
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10871 {
10872
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10873 return qe_invalid;
10874
10875
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&flip,f,keepdata))
10876 return qe_invalid;
10877
10878
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&extend,f,keepdata))
10879 return qe_invalid;
10880
10881
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10882 {
10883 88 setSprite(shocked_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10884 88 }
10885 88 }
10886
10887
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10888 {
10889
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10890 return qe_invalid;
10891
10892
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
10893 return qe_invalid;
10894
10895
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
10896 return qe_invalid;
10897
10898
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10899 {
10900 88 setSprite(pullswordspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10901 88 }
10902 88 }
10903
10904
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10905 {
10906
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10907 return qe_invalid;
10908
10909
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&flip,f,keepdata))
10910 return qe_invalid;
10911
10912
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&extend,f,keepdata))
10913 return qe_invalid;
10914
10915
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10916 {
10917 88 setSprite(readingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10918 88 }
10919 88 }
10920
10921
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10922 {
10923
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_igetl(&tile,f,keepdata))
10924 return qe_invalid;
10925
10926
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&flip,f,keepdata))
10927 return qe_invalid;
10928
10929
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
10930 return qe_invalid;
10931
10932
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10933 {
10934 88 setSprite(slash180spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10935 88 }
10936 88 }
10937
10938
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10939 {
10940
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10941 return qe_invalid;
10942
10943
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&flip,f,keepdata))
10944 return qe_invalid;
10945
10946
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&extend,f,keepdata))
10947 return qe_invalid;
10948
10949
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10950 {
10951 88 setSprite(slashZ4spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10952 88 }
10953 88 }
10954
10955
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10956 {
10957
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10958 return qe_invalid;
10959
10960
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&flip,f,keepdata))
10961 return qe_invalid;
10962
10963
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&extend,f,keepdata))
10964 return qe_invalid;
10965
10966
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10967 {
10968 88 setSprite(dashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10969 88 }
10970 88 }
10971
10972
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10973 {
10974
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10975 return qe_invalid;
10976
10977
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&flip,f,keepdata))
10978 return qe_invalid;
10979
10980
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&extend,f,keepdata))
10981 return qe_invalid;
10982
10983
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10984 {
10985 88 setSprite(bonkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10986 88 }
10987 88 }
10988
10989
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 22 times.
88 for(int32_t q = 0; q < 3; ++q) //Not directions; number of medallion sprs
10990 {
10991
1/2
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
66 if(!p_igetl(&tile,f,keepdata))
10992 return qe_invalid;
10993
10994
1/2
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
66 if(!p_getc(&flip,f,keepdata))
10995 return qe_invalid;
10996
10997
1/2
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
66 if(!p_getc(&extend,f,keepdata))
10998 return qe_invalid;
10999
11000
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
66 if(keepdata)
11001 {
11002 66 setSprite(medallionsprs[q], int32_t(tile), int32_t(flip), int32_t(extend));
11003 66 }
11004 66 }
11005 22 }
11006 else if(keepdata)
11007 {
11008 memset(frozenspr, 0, sizeof(frozenspr));
11009 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
11010 memset(onfirespr, 0, sizeof(onfirespr));
11011 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
11012 memset(diggingspr, 0, sizeof(diggingspr));
11013 memset(usingrodspr, 0, sizeof(usingrodspr));
11014 memset(usingcanespr, 0, sizeof(usingcanespr));
11015 memset(pushingspr, 0, sizeof(pushingspr));
11016 memset(liftingspr, 0, sizeof(liftingspr));
11017 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
11018 memset(stunnedspr, 0, sizeof(stunnedspr));
11019 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
11020 memset(fallingspr, 0, sizeof(fallingspr));
11021 memset(shockedspr, 0, sizeof(shockedspr));
11022 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
11023 memset(pullswordspr, 0, sizeof(pullswordspr));
11024 memset(readingspr, 0, sizeof(readingspr));
11025 memset(slash180spr, 0, sizeof(slash180spr));
11026 memset(slashZ4spr, 0, sizeof(slashZ4spr));
11027 memset(dashspr, 0, sizeof(dashspr));
11028 memset(bonkspr, 0, sizeof(bonkspr));
11029 memset(medallionsprs, 0, sizeof(medallionsprs));
11030 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
11031 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
11032 for(int32_t q = 0; q < 4; ++q)
11033 {
11034 for(int32_t p = 0; p < 3; ++p)
11035 {
11036 drowningspr[q][p] = divespr[q][p];
11037 drowning_lavaspr[q][p] = divespr[q][p];
11038 }
11039 }
11040 }
11041
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if (v_herosprites > 8)
11042 {
11043
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
11044 {
11045
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
11046 return qe_invalid;
11047
11048
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
11049 return qe_invalid;
11050
11051
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
11052 return qe_invalid;
11053
11054
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
11055 {
11056 88 setSprite(sideswimspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11057 88 }
11058 88 }
11059 22 }
11060 else if (keepdata)
11061 {
11062 memset(sideswimspr, 0, sizeof(sideswimspr));
11063 }
11064
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if (v_herosprites > 9)
11065 {
11066
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
11067 {
11068
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
11069 return qe_invalid;
11070
11071
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
11072 return qe_invalid;
11073
11074
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
11075 return qe_invalid;
11076
11077
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
11078 {
11079 88 setSprite(sideswimslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11080 88 }
11081 88 }
11082
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
11083 {
11084
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
11085 return qe_invalid;
11086
11087
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
11088 return qe_invalid;
11089
11090
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
11091 return qe_invalid;
11092
11093
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
11094 {
11095 88 setSprite(sideswimstabspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11096 88 }
11097 88 }
11098
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
11099 {
11100
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
11101 return qe_invalid;
11102
11103
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
11104 return qe_invalid;
11105
11106
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
11107 return qe_invalid;
11108
11109
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
11110 {
11111 88 setSprite(sideswimpoundspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11112 88 }
11113 88 }
11114
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
11115 {
11116
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
11117 return qe_invalid;
11118
11119
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
11120 return qe_invalid;
11121
11122
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
11123 return qe_invalid;
11124
11125
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
11126 {
11127 88 setSprite(sideswimchargespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11128 88 }
11129 88 }
11130 22 }
11131 else if (keepdata)
11132 {
11133 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
11134 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
11135 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
11136 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
11137 }
11138
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if (v_herosprites > 10)
11139 {
11140
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
11141 {
11142 int32_t hmr;
11143
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_igetl(&hmr,f,keepdata))
11144 return qe_invalid;
11145
11146
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
11147 {
11148 88 hammeroffsets[q] = hmr;
11149 88 }
11150 88 }
11151 22 }
11152 else if (keepdata)
11153 {
11154 for(int32_t q = 0; q < 4; ++q) hammeroffsets[q] = 0;
11155 }
11156
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if (v_herosprites > 11)
11157 {
11158
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 22 times.
88 for(int32_t q = 0; q < 3; ++q)
11159 {
11160
1/2
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
66 if(!p_igetl(&tile,f,keepdata))
11161 return qe_invalid;
11162
11163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
66 if(!p_getc(&flip,f,keepdata))
11164 return qe_invalid;
11165
11166
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
66 if(!p_getc(&extend,f,keepdata))
11167 return qe_invalid;
11168
11169
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
66 if(keepdata)
11170 {
11171 66 setSprite(sideswimholdspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11172 66 }
11173 66 }
11174 22 }
11175 else if (keepdata)
11176 {
11177 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
11178 }
11179
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if (v_herosprites > 12)
11180 {
11181
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(!p_igetl(&tile,f,keepdata))
11182 return qe_invalid;
11183
11184
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(!p_getc(&flip,f,keepdata))
11185 return qe_invalid;
11186
11187
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(!p_getc(&extend,f,keepdata))
11188 return qe_invalid;
11189
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if (keepdata)
11190 {
11191 22 setSprite(sideswimcastingspr, int32_t(tile), int32_t(flip), int32_t(extend));
11192 22 }
11193
11194 22 }
11195 else if (keepdata)
11196 {
11197 memset(sideswimcastingspr, 0, sizeof(sideswimcastingspr));
11198 }
11199
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if (v_herosprites > 13)
11200 {
11201
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
11202 {
11203
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
11204 return qe_invalid;
11205
11206
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
11207 return qe_invalid;
11208
11209
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
11210 return qe_invalid;
11211
11212
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
11213 {
11214 88 setSprite(sidedrowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11215 88 }
11216 88 }
11217 22 }
11218 else if (keepdata)
11219 {
11220 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
11221 }
11222
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if (v_herosprites > 14)
11223 {
11224
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
11225 {
11226
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
11227 return qe_invalid;
11228
11229
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
11230 return qe_invalid;
11231
11232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
11233 return qe_invalid;
11234
11235
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
11236 {
11237 88 setSprite(revslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11238 88 }
11239 88 }
11240 22 }
11241 else if (keepdata)
11242 {
11243 memset(revslashspr, 0, sizeof(revslashspr));
11244 }
11245
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if (v_herosprites > 7)
11246 {
11247 22 int32_t num_defense = wMax;
11248 22 byte def = 0;
11249
11250 //Set num_defense accordingly if changes to enum require version upgrade - Jman
11251 /*if(v_herosprites > [x])
11252 * {
11253 * num_defense = 146 //value of wMax on version 8
11254 * }
11255 */
11256
11257
2/2
✓ Branch 0 taken 3212 times.
✓ Branch 1 taken 22 times.
3234 for (int32_t q = 0; q < num_defense; q++)
11258 {
11259
1/2
✓ Branch 0 taken 3212 times.
✗ Branch 1 not taken.
3212 if (!p_getc(&def, f, keepdata))
11260 return qe_invalid;
11261
11262
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3212 times.
3212 if (keepdata)
11263 {
11264 3212 hero_defence[q] = def;
11265 3212 }
11266 3212 }
11267 22 }
11268 else if (keepdata)
11269 {
11270 int32_t num_defense = wMax;
11271 for (int32_t q = 0; q < num_defense; q++)
11272 {
11273 hero_defence[q] = 0;
11274 }
11275 }
11276 22 }
11277
11278 22 return 0;
11279 22 }
11280
11281
11282 96 int32_t readherosprites(PACKFILE *f, zquestheader *Header, bool keepdata)
11283 {
11284 //these are here to bypass compiler warnings about unused arguments
11285 96 Header=Header;
11286
11287 dword dummy;
11288 96 word s_version=0, s_cversion=0;
11289
11290 //section version info
11291
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_igetw(&s_version,f,true))
11292 {
11293 return qe_invalid;
11294 }
11295
11296 96 FFCore.quest_format[vHeroSprites] = s_version;
11297
11298 //al_trace("Player sprites version %d\n", s_version);
11299
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetw(&s_cversion,f,true))
11300 {
11301 return qe_invalid;
11302 }
11303
11304 //section size
11305
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&dummy,f,true))
11306 {
11307 return qe_invalid;
11308 }
11309
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 74 times.
96 if ( s_version >= 6 )
11310 {
11311 //al_trace("Reading Player Sprites v6\n");
11312 22 return readherosprites3(f, s_version, dummy, keepdata);
11313 }
11314 74 else return readherosprites2(f, s_version, dummy, keepdata);
11315 96 }
11316
11317 96 int32_t readsubscreens(PACKFILE *f, zquestheader *Header, bool keepdata)
11318 {
11319 int32_t dummy;
11320 96 word s_version=0, s_cversion=0;
11321
11322 //section version info
11323
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_igetw(&s_version,f,true))
11324 {
11325 return qe_invalid;
11326 }
11327
11328 96 FFCore.quest_format[vSubscreen] = s_version;
11329
11330 //al_trace("Subscreens version %d\n", s_version);
11331
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetw(&s_cversion,f,true))
11332 {
11333 return qe_invalid;
11334 }
11335
11336 //section size
11337
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&dummy,f,true))
11338 {
11339 return qe_invalid;
11340 }
11341
11342 //finally... section data
11343
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 96 times.
12384 for(int32_t i=0; i<MAXCUSTOMSUBSCREENS; i++)
11344 {
11345 12288 int32_t ret = read_one_subscreen(f, Header, keepdata, i, s_version, s_cversion);
11346
11347
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(ret!=0) return ret;
11348 12288 }
11349
11350 96 return 0;
11351 96 }
11352
11353 12288 int32_t read_one_subscreen(PACKFILE *f, zquestheader *, bool keepdata, int32_t i, word s_version, word)
11354 {
11355 12288 int32_t numsub=0;
11356 12288 byte temp_ss=0;
11357 subscreen_object temp_sub_stack;
11358 12288 subscreen_object *temp_sub = &temp_sub_stack;
11359
11360 char tempname[64];
11361
11362
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12288 times.
12288 if(!pfread(tempname,64,f,true))
11363 {
11364 return qe_invalid;
11365 }
11366
11367
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12288 times.
12288 if(s_version > 1)
11368 {
11369
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_getc(&temp_ss,f,keepdata))
11370 {
11371 return qe_invalid;
11372 }
11373 12288 }
11374
11375
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12288 times.
12288 if(s_version < 4)
11376 {
11377 uint8_t tmp=0;
11378
11379 if(!p_getc(&tmp,f,true))
11380 {
11381 return qe_invalid;
11382 }
11383
11384 numsub = (int32_t)tmp;
11385 }
11386 else
11387 {
11388 word tmp;
11389
11390
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetw(&tmp, f, true))
11391 {
11392 return qe_invalid;
11393 }
11394
11395 12288 numsub = (int32_t)tmp;
11396 }
11397
11398 int32_t j;
11399
11400
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 32006 times.
✓ Branch 2 taken 19718 times.
✓ Branch 3 taken 12288 times.
32006 for(j=0; (j<MAXSUBSCREENITEMS&&j<numsub); j++)
11401 {
11402
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19718 times.
19718 if(keepdata)
11403 {
11404 19718 memset(temp_sub,0,sizeof(subscreen_object));
11405
11406
2/2
✓ Branch 0 taken 1147 times.
✓ Branch 1 taken 18571 times.
19718 switch(custom_subscreen[i].objects[j].type)
11407 {
11408 case ssoTEXT:
11409 case ssoTEXTBOX:
11410 case ssoCURRENTITEMTEXT:
11411 case ssoCURRENTITEMCLASSTEXT:
11412
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1147 times.
✓ Branch 2 taken 1147 times.
✗ Branch 3 not taken.
1147 if(custom_subscreen[i].objects[j].dp1 != NULL) delete [](char *)custom_subscreen[i].objects[j].dp1;
11413
11414 //fall through
11415 default:
11416 19718 memset(&custom_subscreen[i].objects[j],0,sizeof(subscreen_object));
11417 19718 break;
11418 }
11419 19718 }
11420
11421
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_getc(&(temp_sub->type),f,true))
11422 {
11423 return qe_invalid;
11424 }
11425
11426
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_getc(&(temp_sub->pos),f,keepdata))
11427 {
11428 return qe_invalid;
11429 }
11430
11431
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(s_version < 5)
11432 {
11433 switch(temp_sub->pos)
11434 {
11435 case 0:
11436 temp_sub->pos = sspUP | sspDOWN | sspSCROLLING;
11437 break;
11438
11439 case 1:
11440 temp_sub->pos = sspUP;
11441 break;
11442
11443 case 2:
11444 temp_sub->pos = sspDOWN;
11445 break;
11446
11447 default:
11448 temp_sub->pos = 0;
11449 }
11450 }
11451
11452
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_igetw(&(temp_sub->x),f,keepdata))
11453 {
11454 return qe_invalid;
11455 }
11456
11457
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_igetw(&(temp_sub->y),f,keepdata))
11458 {
11459 return qe_invalid;
11460 }
11461
11462
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_igetw(&(temp_sub->w),f,keepdata))
11463 {
11464 return qe_invalid;
11465 }
11466
11467
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_igetw(&(temp_sub->h),f,keepdata))
11468 {
11469 return qe_invalid;
11470 }
11471
11472
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_getc(&(temp_sub->colortype1),f,keepdata))
11473 {
11474 return qe_invalid;
11475 }
11476
11477
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_igetw(&(temp_sub->color1),f,keepdata))
11478 {
11479 return qe_invalid;
11480 }
11481
11482
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_getc(&(temp_sub->colortype2),f,keepdata))
11483 {
11484 return qe_invalid;
11485 }
11486
11487
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_igetw(&(temp_sub->color2),f,keepdata))
11488 {
11489 return qe_invalid;
11490 }
11491
11492
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_getc(&(temp_sub->colortype3),f,keepdata))
11493 {
11494 return qe_invalid;
11495 }
11496
11497
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_igetw(&(temp_sub->color3),f,keepdata))
11498 {
11499 return qe_invalid;
11500 }
11501
11502
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_igetd(&(temp_sub->d1),f,keepdata))
11503 {
11504 return qe_invalid;
11505 }
11506
11507
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_igetd(&(temp_sub->d2),f,keepdata))
11508 {
11509 return qe_invalid;
11510 }
11511
11512
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_igetd(&(temp_sub->d3),f,keepdata))
11513 {
11514 return qe_invalid;
11515 }
11516
11517
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_igetd(&(temp_sub->d4),f,keepdata))
11518 {
11519 return qe_invalid;
11520 }
11521
11522
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_igetd(&(temp_sub->d5),f,keepdata))
11523 {
11524 return qe_invalid;
11525 }
11526
11527
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_igetd(&(temp_sub->d6),f,keepdata))
11528 {
11529 return qe_invalid;
11530 }
11531
11532
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_igetd(&(temp_sub->d7),f,keepdata))
11533 {
11534 return qe_invalid;
11535 }
11536
11537
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_igetd(&(temp_sub->d8),f,keepdata))
11538 {
11539 return qe_invalid;
11540 }
11541
11542
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_igetd(&(temp_sub->d9),f,keepdata))
11543 {
11544 return qe_invalid;
11545 }
11546
11547
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_igetd(&(temp_sub->d10),f,keepdata))
11548 {
11549 return qe_invalid;
11550 }
11551
11552
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19718 times.
19718 if(s_version < 2)
11553 {
11554 if(!p_igetl(&(temp_sub->speed),f,keepdata))
11555 {
11556 return qe_invalid;
11557 }
11558
11559 if(!p_igetl(&(temp_sub->delay),f,keepdata))
11560 {
11561 return qe_invalid;
11562 }
11563
11564 if(!p_igetl(&(temp_sub->frame),f,keepdata))
11565 {
11566 return qe_invalid;
11567 }
11568 }
11569 else
11570 {
11571
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_getc(&(temp_sub->speed),f,keepdata))
11572 {
11573 return qe_invalid;
11574 }
11575
11576
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_getc(&(temp_sub->delay),f,keepdata))
11577 {
11578 return qe_invalid;
11579 }
11580
11581
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_igetw(&(temp_sub->frame),f,keepdata))
11582 {
11583 return qe_invalid;
11584 }
11585 }
11586
11587 19718 int32_t temp_size=0;
11588
11589 // bool deletets = false;
11590
4/4
✓ Branch 0 taken 8380 times.
✓ Branch 1 taken 1605 times.
✓ Branch 2 taken 9590 times.
✓ Branch 3 taken 143 times.
19718 switch(temp_sub->type)
11591 {
11592 case ssoTEXT:
11593 case ssoTEXTBOX:
11594 case ssoCURRENTITEMTEXT:
11595 case ssoCURRENTITEMCLASSTEXT:
11596 word temptempsize;
11597 /*uint8_t temp1;
11598 uint8_t temp2;
11599 temp2 = 0;
11600 if(!p_getc(&temp1,f,true))
11601 {
11602 return qe_invalid;
11603 }
11604 if(temp1)
11605 {
11606
11607 if(!p_getc(&temp2,f,true))
11608 {
11609 return qe_invalid;
11610 }
11611 }*/
11612
11613
1/2
✓ Branch 0 taken 1605 times.
✗ Branch 1 not taken.
1605 if(!p_igetw(&temptempsize,f,true))
11614 {
11615 return qe_invalid;
11616 }
11617
11618 //temptempsize = temp1 + (temp2 << 8);
11619 1605 temp_size = (int32_t)temptempsize;
11620
11621 //if(temp_sub->dp1!=NULL) delete[] temp_sub->dp1;
11622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1605 times.
1605 if(keepdata)
11623 {
11624 1605 uint32_t char_length = temp_size+1;
11625 1605 temp_sub->dp1 = new char[char_length]; //memory not freed
11626
11627 //deletets = true; //obsolete
11628 1605 }
11629
11630
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1605 times.
1605 if(temp_size)
11631 {
11632
1/2
✓ Branch 0 taken 1605 times.
✗ Branch 1 not taken.
1605 if(!pfread(temp_sub->dp1,temp_size+1,f,keepdata))
11633 {
11634 return qe_invalid;
11635 }
11636 1605 }
11637
11638 1605 break;
11639
11640 case ssoLIFEMETER:
11641
1/2
✓ Branch 0 taken 143 times.
✗ Branch 1 not taken.
143 if(get_bit(deprecated_rules, 12) != 0) // qr_24HC
11642 temp_sub->d3 = 1;
11643
11644
1/2
✓ Branch 0 taken 143 times.
✗ Branch 1 not taken.
143 if(!p_getc(&(temp_sub->dp1),f,keepdata))
11645 {
11646 return qe_invalid;
11647 }
11648
11649 143 break;
11650
11651
11652 case ssoCURRENTITEM:
11653
11654
1/2
✓ Branch 0 taken 8380 times.
✗ Branch 1 not taken.
8380 if(s_version < 6)
11655 {
11656 switch(temp_sub->d1)
11657 {
11658 case ssiBOMB:
11659 temp_sub->d1 = itype_bomb;
11660 break;
11661
11662 case ssiSWORD:
11663 temp_sub->d1 = itype_sword;
11664 break;
11665
11666 case ssiSHIELD:
11667 temp_sub->d1 = itype_shield;
11668 break;
11669
11670 case ssiCANDLE:
11671 temp_sub->d1 = itype_candle;
11672 break;
11673
11674 case ssiLETTER:
11675 temp_sub->d1 = itype_letter;
11676 break;
11677
11678 case ssiPOTION:
11679 temp_sub->d1 = itype_potion;
11680 break;
11681
11682 case ssiLETTERPOTION:
11683 temp_sub->d1 = itype_letterpotion;
11684 break;
11685
11686 case ssiBOW:
11687 temp_sub->d1 = itype_bow;
11688 break;
11689
11690 case ssiARROW:
11691 temp_sub->d1 = itype_arrow;
11692 break;
11693
11694 case ssiBOWANDARROW:
11695 temp_sub->d1 = itype_bowandarrow;
11696 break;
11697
11698 case ssiBAIT:
11699 temp_sub->d1 = itype_bait;
11700 break;
11701
11702 case ssiRING:
11703 temp_sub->d1 = itype_ring;
11704 break;
11705
11706 case ssiBRACELET:
11707 temp_sub->d1 = itype_bracelet;
11708 break;
11709
11710 case ssiMAP:
11711 temp_sub->d1 = itype_map;
11712 break;
11713
11714 case ssiCOMPASS:
11715 temp_sub->d1 = itype_compass;
11716 break;
11717
11718 case ssiBOSSKEY:
11719 temp_sub->d1 = itype_bosskey;
11720 break;
11721
11722 case ssiMAGICKEY:
11723 temp_sub->d1 = itype_magickey;
11724 break;
11725
11726 case ssiBRANG:
11727 temp_sub->d1 = itype_brang;
11728 break;
11729
11730 case ssiWAND:
11731 temp_sub->d1 = itype_wand;
11732 break;
11733
11734 case ssiRAFT:
11735 temp_sub->d1 = itype_raft;
11736 break;
11737
11738 case ssiLADDER:
11739 temp_sub->d1 = itype_ladder;
11740 break;
11741
11742 case ssiWHISTLE:
11743 temp_sub->d1 = itype_whistle;
11744 break;
11745
11746 case ssiBOOK:
11747 temp_sub->d1 = itype_book;
11748 break;
11749
11750 case ssiWALLET:
11751 temp_sub->d1 = itype_wallet;
11752 break;
11753
11754 case ssiSBOMB:
11755 temp_sub->d1 = itype_sbomb;
11756 break;
11757
11758 case ssiHCPIECE:
11759 temp_sub->d1 = itype_heartpiece;
11760 break;
11761
11762 case ssiAMULET:
11763 temp_sub->d1 = itype_amulet;
11764 break;
11765
11766 case ssiFLIPPERS:
11767 temp_sub->d1 = itype_flippers;
11768 break;
11769
11770 case ssiHOOKSHOT:
11771 temp_sub->d1 = itype_hookshot;
11772 break;
11773
11774 case ssiLENS:
11775 temp_sub->d1 = itype_lens;
11776 break;
11777
11778 case ssiHAMMER:
11779 temp_sub->d1 = itype_hammer;
11780 break;
11781
11782 case ssiBOOTS:
11783 temp_sub->d1 = itype_boots;
11784 break;
11785
11786 case ssiDINSFIRE:
11787 temp_sub->d1 = itype_dinsfire;
11788 break;
11789
11790 case ssiFARORESWIND:
11791 temp_sub->d1 = itype_faroreswind;
11792 break;
11793
11794 case ssiNAYRUSLOVE:
11795 temp_sub->d1 = itype_nayruslove;
11796 break;
11797
11798 case ssiQUIVER:
11799 temp_sub->d1 = itype_quiver;
11800 break;
11801
11802 case ssiBOMBBAG:
11803 temp_sub->d1 = itype_bombbag;
11804 break;
11805
11806 case ssiCBYRNA:
11807 temp_sub->d1 = itype_cbyrna;
11808 break;
11809
11810 case ssiROCS:
11811 temp_sub->d1 = itype_rocs;
11812 break;
11813
11814 case ssiHOVERBOOTS:
11815 temp_sub->d1 = itype_hoverboots;
11816 break;
11817
11818 case ssiSPINSCROLL:
11819 temp_sub->d1 = itype_spinscroll;
11820 break;
11821
11822 case ssiCROSSSCROLL:
11823 temp_sub->d1 = itype_crossscroll;
11824 break;
11825
11826 case ssiQUAKESCROLL:
11827 temp_sub->d1 = itype_quakescroll;
11828 break;
11829
11830 case ssiWHISPRING:
11831 temp_sub->d1 = itype_whispring;
11832 break;
11833
11834 case ssiCHARGERING:
11835 temp_sub->d1 = itype_chargering;
11836 break;
11837
11838 case ssiPERILSCROLL:
11839 temp_sub->d1 = itype_perilscroll;
11840 break;
11841
11842 case ssiWEALTHMEDAL:
11843 temp_sub->d1 = itype_wealthmedal;
11844 break;
11845
11846 case ssiHEARTRING:
11847 temp_sub->d1 = itype_heartring;
11848 break;
11849
11850 case ssiMAGICRING:
11851 temp_sub->d1 = itype_magicring;
11852 break;
11853
11854 case ssiSPINSCROLL2:
11855 temp_sub->d1 = itype_spinscroll2;
11856 break;
11857
11858 case ssiQUAKESCROLL2:
11859 temp_sub->d1 = itype_quakescroll2;
11860 break;
11861
11862 case ssiAGONY:
11863 temp_sub->d1 = itype_agony;
11864 break;
11865
11866 case ssiSTOMPBOOTS:
11867 temp_sub->d1 = itype_stompboots;
11868 break;
11869
11870 case ssiWHIMSICALRING:
11871 temp_sub->d1 = itype_whimsicalring;
11872 break;
11873
11874 case ssiPERILRING:
11875 temp_sub->d1 = itype_perilring;
11876 break;
11877
11878 default:
11879 temp_sub->d1 += itype_custom1 - ssiMAX;
11880 }
11881 }
11882
11883 //fall-through
11884 default:
11885
1/2
✓ Branch 0 taken 17970 times.
✗ Branch 1 not taken.
17970 if(!p_getc(&(temp_sub->dp1),f,keepdata))
11886 {
11887 return qe_invalid;
11888 }
11889
11890 17970 break;
11891 }
11892
11893
2/2
✓ Branch 0 taken 11341 times.
✓ Branch 1 taken 8377 times.
19718 if(s_version < 7)
11894 {
11895
3/3
✓ Branch 0 taken 7837 times.
✓ Branch 1 taken 204 times.
✓ Branch 2 taken 336 times.
8377 switch(temp_sub->type)
11896 {
11897 case ssoMAGICGAUGE:
11898 {
11899
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 192 times.
204 if(!temp_sub->d9)
11900 192 temp_sub->d9 = -1; //-1 now represents 'always'
11901 204 break;
11902 }
11903 case ssoLIFEGAUGE:
11904 336 temp_sub->d9 = 0; //Unused, doesn't do anything? Clear it...
11905 336 break;
11906 }
11907 8377 }
11908
11909
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19718 times.
19718 if(keepdata)
11910 {
11911
3/3
✓ Branch 0 taken 1605 times.
✓ Branch 1 taken 17267 times.
✓ Branch 2 taken 846 times.
19718 switch(temp_sub->type)
11912 {
11913 case ssoTEXT:
11914 case ssoTEXTBOX:
11915 case ssoCURRENTITEMTEXT:
11916 case ssoCURRENTITEMCLASSTEXT:
11917
1/4
✓ Branch 0 taken 1605 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1605 if(custom_subscreen[i].objects[j].dp1 != NULL) delete[](char *)custom_subscreen[i].objects[j].dp1;
11918
11919 1605 memcpy(&custom_subscreen[i].objects[j],temp_sub,sizeof(subscreen_object));
11920 1605 custom_subscreen[i].objects[j].dp1 = NULL;
11921 1605 custom_subscreen[i].objects[j].dp1 = new char[temp_size+1];
11922 1605 strcpy((char*)custom_subscreen[i].objects[j].dp1,(char*)temp_sub->dp1);
11923 1605 break;
11924
11925 case ssoCOUNTER:
11926
1/2
✓ Branch 0 taken 846 times.
✗ Branch 1 not taken.
846 if(s_version<3)
11927 {
11928 temp_sub->d6=(temp_sub->d6?1:0)+(temp_sub->d8?2:0);
11929 temp_sub->d8=0;
11930 }
11931
11932 default:
11933 18113 memcpy(&custom_subscreen[i].objects[j],temp_sub,sizeof(subscreen_object));
11934 18113 break;
11935 }
11936
11937 19718 strcpy(custom_subscreen[i].name, tempname);
11938 19718 custom_subscreen[i].ss_type = temp_ss;
11939 19718 }
11940 19718 }
11941
11942
2/2
✓ Branch 0 taken 3126010 times.
✓ Branch 1 taken 12288 times.
3138298 for(j=numsub; j<MAXSUBSCREENITEMS; j++)
11943 {
11944
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3126010 times.
3126010 if(keepdata)
11945 {
11946 //clear all unused object in this subscreen -DD
11947
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3126010 times.
3126010 switch(custom_subscreen[i].objects[j].type)
11948 {
11949 case ssoTEXT:
11950 case ssoTEXTBOX:
11951 case ssoCURRENTITEMTEXT:
11952 case ssoCURRENTITEMCLASSTEXT:
11953 if(custom_subscreen[i].objects[j].dp1 != NULL) delete [](char *)custom_subscreen[i].objects[j].dp1;
11954
11955 //fall through
11956 default:
11957 3126010 memset(&custom_subscreen[i].objects[j],0,sizeof(subscreen_object));
11958 3126010 break;
11959 }
11960 3126010 }
11961 3126010 }
11962
11963 12288 return 0;
11964 12288 }
11965
11966 2048 void reset_subscreen(subscreen_group *tempss)
11967 {
11968
2/2
✓ Branch 0 taken 524288 times.
✓ Branch 1 taken 2048 times.
526336 for(int32_t i=0; i<MAXSUBSCREENITEMS; ++i)
11969 {
11970
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 524177 times.
524288 switch(tempss->objects[i].type)
11971 {
11972 case ssoTEXT:
11973 case ssoTEXTBOX:
11974 case ssoCURRENTITEMTEXT:
11975 case ssoCURRENTITEMCLASSTEXT:
11976
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
111 if(tempss->objects[i].dp1 != NULL) delete [](char *)tempss->objects[i].dp1;
11977
11978 //fall through
11979 default:
11980 524288 memset(&tempss->objects[i],0,sizeof(subscreen_object));
11981 524288 break;
11982 }
11983 524288 }
11984 2048 }
11985
11986 16 void reset_subscreens()
11987 {
11988
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 16 times.
2064 for(int32_t i=0; i<MAXCUSTOMSUBSCREENS; ++i)
11989 {
11990 2048 reset_subscreen(&custom_subscreen[i]);
11991 2048 }
11992 16 }
11993
11994 16 int32_t setupsubscreens()
11995 {
11996 16 reset_subscreens();
11997 16 int32_t tempsubscreen=zinit.subscreen;
11998 subscreen_object *tempsub;
11999
12000
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempsubscreen>=ssdtMAX)
12001 {
12002 tempsubscreen=0;
12003 }
12004
12005
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
16 switch(tempsubscreen)
12006 {
12007 case ssdtOLD:
12008 case ssdtNEWSUBSCR:
12009 case ssdtREV2:
12010 case ssdtBSZELDA:
12011 case ssdtBSZELDAMODIFIED:
12012 case ssdtBSZELDAENHANCED:
12013 case ssdtBSZELDACOMPLETE:
12014 {
12015 16 tempsub = default_subscreen_active[tempsubscreen][0];
12016 int32_t i;
12017
12018
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1056 times.
✓ Branch 2 taken 1040 times.
✓ Branch 3 taken 16 times.
1056 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12019 {
12020
2/3
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 992 times.
✗ Branch 2 not taken.
1040 switch(tempsub[i].type)
12021 {
12022 case ssoTEXT:
12023 case ssoTEXTBOX:
12024 case ssoCURRENTITEMTEXT:
12025 case ssoCURRENTITEMCLASSTEXT:
12026
1/4
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
48 if(custom_subscreen[0].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[0].objects[i].dp1;
12027
12028 48 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12029 48 custom_subscreen[0].objects[i].dp1 = NULL;
12030 48 custom_subscreen[0].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12031 48 strcpy((char*)custom_subscreen[0].objects[i].dp1,(char*)tempsub[i].dp1);
12032 48 break;
12033
12034 case ssoLIFEMETER:
12035 {
12036 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12037
12038 if(get_bit(deprecated_rules, 12) != 0)
12039 custom_subscreen[0].objects[i].d3=1;
12040 else
12041 custom_subscreen[0].objects[i].d3=0;
12042
12043 break;
12044 }
12045 /*
12046 case ssoTRIFRAME:
12047 {
12048 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12049 custom_subscreen[0].objects[i].d1 = 8594;
12050 custom_subscreen[0].objects[i].d2 = 8;
12051 custom_subscreen[0].objects[i].d3 = 8771;
12052 custom_subscreen[0].objects[i].d4 = 8;
12053 custom_subscreen[0].objects[i].d5 = 1;
12054 custom_subscreen[0].objects[i].d6 = 1;
12055 break;
12056 }*/
12057
12058 default:
12059 992 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12060 992 break;
12061 }
12062 1040 }
12063
12064 16 custom_subscreen[0].ss_type=sstACTIVE;
12065 16 sprintf(custom_subscreen[0].name, "Active Subscreen (Triforce)");
12066 16 tempsub = default_subscreen_active[tempsubscreen][1];
12067
12068
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1056 times.
✓ Branch 2 taken 1040 times.
✓ Branch 3 taken 16 times.
1056 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12069 {
12070
2/3
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 976 times.
✗ Branch 2 not taken.
1040 switch(tempsub[i].type)
12071 {
12072 case ssoTEXT:
12073 case ssoTEXTBOX:
12074 case ssoCURRENTITEMTEXT:
12075 case ssoCURRENTITEMCLASSTEXT:
12076
1/4
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
64 if(custom_subscreen[1].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[1].objects[i].dp1;
12077
12078 64 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12079 64 custom_subscreen[1].objects[i].dp1 = NULL;
12080 64 custom_subscreen[1].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12081 64 strcpy((char*)custom_subscreen[1].objects[i].dp1,(char*)tempsub[i].dp1);
12082 64 break;
12083
12084 case ssoLIFEMETER:
12085 {
12086 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12087
12088 if(get_bit(deprecated_rules, 12) != 0)
12089 custom_subscreen[1].objects[i].d3=1;
12090 else
12091 custom_subscreen[1].objects[i].d3=0;
12092
12093 break;
12094 }
12095 /*
12096 case ssoTRIFRAME:
12097 {
12098 custom_subscreen[1].objects[i].d1 = 8594;
12099 custom_subscreen[1].objects[i].d2 = 8;
12100 custom_subscreen[1].objects[i].d3 = 8771;
12101 custom_subscreen[1].objects[i].d4 = 8;
12102 custom_subscreen[1].objects[i].d5 = 1;
12103 custom_subscreen[1].objects[i].d6 = 1;
12104 break;
12105 }*/
12106
12107 default:
12108 976 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12109 976 break;
12110 }
12111 1040 }
12112
12113 16 custom_subscreen[1].ss_type=sstACTIVE;
12114 16 sprintf(custom_subscreen[1].name, "Active Subscreen (Dungeon Map)");
12115 // memset(&custom_subscreen[1].objects[i],0,sizeof(subscreen_object));
12116 16 tempsub = default_subscreen_passive[tempsubscreen][0];
12117
12118
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 336 times.
✓ Branch 2 taken 320 times.
✓ Branch 3 taken 16 times.
336 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12119 {
12120
3/3
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 256 times.
✓ Branch 2 taken 16 times.
320 switch(tempsub[i].type)
12121 {
12122 case ssoTEXT:
12123 case ssoTEXTBOX:
12124 case ssoCURRENTITEMTEXT:
12125 case ssoCURRENTITEMCLASSTEXT:
12126
1/4
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
48 if(custom_subscreen[2].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[2].objects[i].dp1;
12127
12128 48 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12129 48 custom_subscreen[2].objects[i].dp1 = NULL;
12130 48 custom_subscreen[2].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12131 48 strcpy((char*)custom_subscreen[2].objects[i].dp1,(char*)tempsub[i].dp1);
12132 48 break;
12133
12134 case ssoLIFEMETER:
12135 {
12136 16 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12137
12138
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 13 times.
16 if(get_bit(deprecated_rules, 12) != 0)
12139 3 custom_subscreen[2].objects[i].d3=1;
12140 else
12141 13 custom_subscreen[2].objects[i].d3=0;
12142
12143 16 break;
12144 }
12145
12146 default:
12147 256 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12148 256 break;
12149 }
12150 320 }
12151
12152 16 custom_subscreen[2].ss_type=sstPASSIVE;
12153 16 sprintf(custom_subscreen[2].name, "Passive Subscreen (Magic)");
12154 // memset(&custom_subscreen[2].objects[i],0,sizeof(subscreen_object));
12155 16 tempsub = default_subscreen_passive[tempsubscreen][1];
12156
12157
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 320 times.
✓ Branch 2 taken 304 times.
✓ Branch 3 taken 16 times.
320 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12158 {
12159
3/3
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 240 times.
✓ Branch 2 taken 16 times.
304 switch(tempsub[i].type)
12160 {
12161 case ssoTEXT:
12162 case ssoTEXTBOX:
12163 case ssoCURRENTITEMTEXT:
12164 case ssoCURRENTITEMCLASSTEXT:
12165
1/4
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
48 if(custom_subscreen[3].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[3].objects[i].dp1;
12166
12167 48 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12168 48 custom_subscreen[3].objects[i].dp1 = NULL;
12169 48 custom_subscreen[3].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12170 48 strcpy((char*)custom_subscreen[3].objects[i].dp1,(char*)tempsub[i].dp1);
12171 48 break;
12172
12173 case ssoLIFEMETER:
12174 {
12175 16 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12176
12177
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 13 times.
16 if(get_bit(deprecated_rules, 12) != 0)
12178 3 custom_subscreen[3].objects[i].d3=1;
12179 else
12180 13 custom_subscreen[3].objects[i].d3=0;
12181
12182 16 break;
12183 }
12184
12185 default:
12186 240 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12187 240 break;
12188 }
12189 304 }
12190
12191 16 custom_subscreen[3].ss_type=sstPASSIVE;
12192 16 sprintf(custom_subscreen[3].name, "Passive Subscreen (No Magic)");
12193 // memset(&custom_subscreen[3].objects[i],0,sizeof(subscreen_object));
12194 16 break;
12195 }
12196
12197 case ssdtZ3:
12198 {
12199 tempsub = z3_active_a;
12200 int32_t i;
12201
12202 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12203 {
12204 switch(tempsub[i].type)
12205 {
12206 case ssoTEXT:
12207 case ssoTEXTBOX:
12208 case ssoCURRENTITEMTEXT:
12209 case ssoCURRENTITEMCLASSTEXT:
12210 if(custom_subscreen[0].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[0].objects[i].dp1;
12211
12212 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12213 custom_subscreen[0].objects[i].dp1 = NULL;
12214 custom_subscreen[0].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12215 strcpy((char*)custom_subscreen[0].objects[i].dp1,(char*)tempsub[i].dp1);
12216 break;
12217
12218 case ssoLIFEMETER:
12219 {
12220 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12221
12222 if(get_bit(deprecated_rules, 12) != 0)
12223 custom_subscreen[0].objects[i].d3=1;
12224 else
12225 custom_subscreen[0].objects[i].d3=0;
12226
12227 break;
12228 }
12229
12230 default:
12231 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12232 break;
12233 }
12234 }
12235
12236 custom_subscreen[0].ss_type=sstACTIVE;
12237 // memset(&custom_subscreen[0].objects[i],0,sizeof(subscreen_object));
12238 tempsub = z3_active_ab;
12239
12240 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12241 {
12242 switch(tempsub[i].type)
12243 {
12244 case ssoTEXT:
12245 case ssoTEXTBOX:
12246 case ssoCURRENTITEMTEXT:
12247 case ssoCURRENTITEMCLASSTEXT:
12248 if(custom_subscreen[1].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[1].objects[i].dp1;
12249
12250 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12251 custom_subscreen[1].objects[i].dp1 = NULL;
12252 custom_subscreen[1].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12253 strcpy((char*)custom_subscreen[1].objects[i].dp1,(char*)tempsub[i].dp1);
12254 break;
12255
12256 case ssoLIFEMETER:
12257 {
12258 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12259
12260 if(get_bit(deprecated_rules, 12) != 0)
12261 custom_subscreen[1].objects[i].d3=1;
12262 else
12263 custom_subscreen[1].objects[i].d3=0;
12264
12265 break;
12266 }
12267
12268 default:
12269 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12270 break;
12271 }
12272 }
12273
12274 custom_subscreen[1].ss_type=sstACTIVE;
12275 // memset(&custom_subscreen[1].objects[i],0,sizeof(subscreen_object));
12276 tempsub = z3_passive_a;
12277
12278 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12279 {
12280 switch(tempsub[i].type)
12281 {
12282 case ssoTEXT:
12283 case ssoTEXTBOX:
12284 case ssoCURRENTITEMTEXT:
12285 case ssoCURRENTITEMCLASSTEXT:
12286 if(custom_subscreen[2].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[2].objects[i].dp1;
12287
12288 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12289 custom_subscreen[2].objects[i].dp1 = NULL;
12290 custom_subscreen[2].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12291 strcpy((char*)custom_subscreen[2].objects[i].dp1,(char*)tempsub[i].dp1);
12292 break;
12293
12294 case ssoLIFEMETER:
12295 {
12296 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12297
12298 if(get_bit(deprecated_rules, 12) != 0)
12299 custom_subscreen[2].objects[i].d3=1;
12300 else
12301 custom_subscreen[2].objects[i].d3=0;
12302
12303 break;
12304 }
12305
12306 default:
12307 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12308 break;
12309 }
12310 }
12311
12312 custom_subscreen[2].ss_type=sstPASSIVE;
12313 // memset(&custom_subscreen[2].objects[i],0,sizeof(subscreen_object));
12314 tempsub = z3_passive_ab;
12315
12316 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12317 {
12318 switch(tempsub[i].type)
12319 {
12320 case ssoTEXT:
12321 case ssoTEXTBOX:
12322 case ssoCURRENTITEMTEXT:
12323 case ssoCURRENTITEMCLASSTEXT:
12324 if(custom_subscreen[3].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[3].objects[i].dp1;
12325
12326 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12327 custom_subscreen[3].objects[i].dp1 = NULL;
12328 custom_subscreen[3].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12329 strcpy((char*)custom_subscreen[3].objects[i].dp1,(char*)tempsub[i].dp1);
12330 break;
12331
12332 case ssoLIFEMETER:
12333 {
12334 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12335
12336 if(get_bit(deprecated_rules, 12) != 0)
12337 custom_subscreen[3].objects[i].d3=1;
12338 else
12339 custom_subscreen[3].objects[i].d3=0;
12340
12341 break;
12342 }
12343
12344 default:
12345 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12346 break;
12347 }
12348 }
12349
12350 custom_subscreen[3].ss_type=sstPASSIVE;
12351 // memset(&custom_subscreen[3].objects[i],0,sizeof(subscreen_object));
12352 break;
12353 }
12354 }
12355
12356
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 64 times.
80 for(int32_t i=0; i<4; ++i)
12357 {
12358 64 purge_blank_subscreen_objects(&custom_subscreen[i]);
12359 64 }
12360
12361 16 return 0;
12362 }
12363
12364 extern script_data *ffscripts[NUMSCRIPTFFC];
12365 extern script_data *itemscripts[NUMSCRIPTITEM];
12366 extern script_data *guyscripts[NUMSCRIPTGUYS];
12367 extern script_data *wpnscripts[NUMSCRIPTWEAPONS];
12368 extern script_data *lwpnscripts[NUMSCRIPTWEAPONS];
12369 extern script_data *ewpnscripts[NUMSCRIPTWEAPONS];
12370 extern script_data *globalscripts[NUMSCRIPTGLOBAL];
12371 extern script_data *genericscripts[NUMSCRIPTSGENERIC];
12372 extern script_data *playerscripts[NUMSCRIPTPLAYER];
12373 extern script_data *screenscripts[NUMSCRIPTSCREEN];
12374 extern script_data *dmapscripts[NUMSCRIPTSDMAP];
12375 extern script_data *itemspritescripts[NUMSCRIPTSITEMSPRITE];
12376 extern script_data *comboscripts[NUMSCRIPTSCOMBODATA];
12377 //script_data *wpnscripts[NUMSCRIPTWEAPONS]; //used only for old data
12378
12379
12380
12381 96 int32_t readffscript(PACKFILE *f, zquestheader *Header, bool keepdata)
12382 {
12383 int32_t dummy;
12384 96 word s_version=0, s_cversion=0, zmeta_version=0;
12385 96 byte numscripts=0;
12386 96 numscripts=numscripts; //to avoid unused variables warnings
12387 int32_t ret;
12388
12389 //section version info
12390
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_igetw(&s_version,f,true))
12391 {
12392 return qe_invalid;
12393 }
12394
12395 96 FFCore.quest_format[vFFScript] = s_version;
12396
12397
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetw(&s_cversion,f,true))
12398 {
12399 return qe_invalid;
12400 }
12401
12402
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 22 times.
96 if(s_version >= 18)
12403 {
12404
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(!p_igetw(&zmeta_version,f,true))
12405 {
12406 return qe_invalid;
12407 }
12408 22 }
12409
12410 //al_trace("Scripts version %d\n", s_version);
12411 //section size
12412
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&dummy,f,true))
12413 {
12414 return qe_invalid;
12415 }
12416
12417 //ZScriptVersion::setVersion(s_version); ~this ideally, but there's no ZC/ZQuest defines...
12418 96 setZScriptVersion(s_version); //Lumped in zelda.cpp and in zquest.cpp as zquest can't link ZScriptVersion
12419 96 temp_ffscript_version = s_version;
12420 //miscQdata *the_misc;
12421
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 74 times.
96 if ( FFCore.quest_format[vLastCompile] < 13 ) FFCore.quest_format[vLastCompile] = s_version;
12422 96 al_trace("Loaded scripts last compiled in ZScript version: %d\n", (FFCore.quest_format[vLastCompile]));
12423
12424 //finally... section data
12425
2/2
✓ Branch 0 taken 49152 times.
✓ Branch 1 taken 96 times.
49248 for(int32_t i = 0; i < ((s_version < 2) ? NUMSCRIPTFFCOLD : NUMSCRIPTFFC); i++)
12426 {
12427 49152 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &ffscripts[i], zmeta_version);
12428
12429
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(ret != 0) return qe_invalid;
12430 49152 }
12431
12432 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
12433 * This fixes changes to sprite jump values introduced in early 2.55 alphas.
12434 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
12435 * there was a version bump a week before a change that broke stuff.
12436 */
12437
6/8
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 74 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 22 times.
✓ Branch 4 taken 22 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 22 times.
✓ Branch 7 taken 74 times.
96 if(((Header->zelda_version < 0x253)||((Header->zelda_version == 0x253)&&(Header->build<33))||((Header->zelda_version > 0x253) && s_version < 12)) && keepdata)
12438 {
12439 74 set_bit(quest_rules,qr_SPRITE_JUMP_IS_TRUNCATED,1);
12440 74 }
12441
3/4
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 22 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 74 times.
96 if(s_version < 19 && keepdata)
12442 {
12443 74 set_bit(quest_rules,qr_FLUCTUATING_ENEMY_JUMP,1);
12444 74 }
12445
12446
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(s_version > 1)
12447 {
12448
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 96 times.
24672 for(int32_t i = 0; i < NUMSCRIPTITEM; i++)
12449 {
12450 24576 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &itemscripts[i], zmeta_version);
12451
12452
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(ret != 0) return qe_invalid;
12453 24576 }
12454
12455
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 96 times.
24672 for(int32_t i = 0; i < NUMSCRIPTGUYS; i++)
12456 {
12457 24576 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &guyscripts[i], zmeta_version);
12458
12459
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(ret != 0) return qe_invalid;
12460 24576 }
12461
12462
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 96 times.
24672 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12463 {
12464 24576 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &wpnscripts[i], zmeta_version);
12465
12466
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(ret != 0) return qe_invalid;
12467 24576 }
12468
12469
12470
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 96 times.
24672 for(int32_t i = 0; i < NUMSCRIPTSCREEN; i++)
12471 {
12472 24576 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &screenscripts[i], zmeta_version);
12473
12474
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(ret != 0) return qe_invalid;
12475 24576 }
12476
12477
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 74 times.
96 if(s_version > 16)
12478 {
12479
2/2
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 22 times.
198 for(int32_t i = 0; i < NUMSCRIPTGLOBAL; ++i)
12480 {
12481 176 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12482
12483
1/2
✓ Branch 0 taken 176 times.
✗ Branch 1 not taken.
176 if(ret != 0) return qe_invalid;
12484 176 }
12485 22 }
12486
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 else if(s_version > 13)
12487 {
12488 for(int32_t i = 0; i < NUMSCRIPTGLOBAL255OLD; ++i)
12489 {
12490 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12491
12492 if(ret != 0) return qe_invalid;
12493 }
12494
12495 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12496 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12497
12498 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data();
12499 }
12500
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 else if(s_version > 4)
12501 {
12502
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 74 times.
370 for(int32_t i = 0; i < NUMSCRIPTGLOBAL253; ++i)
12503 {
12504 296 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12505
12506
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(ret != 0) return qe_invalid;
12507 296 }
12508
12509
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12510
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12511
12512
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data();
12513
12514
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12515
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12516
12517
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data();
12518
12519
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12520
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 delete globalscripts[GLOBAL_SCRIPT_F6];
12521
12522
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 globalscripts[GLOBAL_SCRIPT_F6] = new script_data();
12523
12524
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12525
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12526
12527
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data();
12528 74 }
12529 else
12530 {
12531 for(int32_t i = 0; i < NUMSCRIPTGLOBALOLD; i++)
12532 {
12533 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12534
12535 if(ret != 0) return qe_invalid;
12536 }
12537
12538 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12539 delete globalscripts[GLOBAL_SCRIPT_ONSAVELOAD];
12540
12541 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] = new script_data();
12542
12543 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12544 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12545
12546 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data();
12547
12548 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12549 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12550
12551 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data();
12552
12553 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12554 delete globalscripts[GLOBAL_SCRIPT_F6];
12555
12556 globalscripts[GLOBAL_SCRIPT_F6] = new script_data();
12557
12558 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12559 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12560
12561 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data();
12562 }
12563
12564
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 74 times.
96 if(s_version > 10) //expanded the number of Player scripts to 5.
12565 {
12566
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 22 times.
132 for(int32_t i = 0; i < NUMSCRIPTPLAYER; i++)
12567 {
12568 110 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &playerscripts[i], zmeta_version);
12569
12570
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(ret != 0) return qe_invalid;
12571 110 }
12572 22 }
12573 else
12574 {
12575
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 74 times.
296 for(int32_t i = 0; i < NUMSCRIPTHEROOLD; i++)
12576 {
12577 222 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &playerscripts[i], zmeta_version);
12578
12579
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(ret != 0) return qe_invalid;
12580 222 }
12581
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 if(playerscripts[3] != NULL)
12582
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 delete playerscripts[3];
12583
12584
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 playerscripts[3] = new script_data();
12585
12586
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 if(playerscripts[4] != NULL)
12587
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 delete playerscripts[4];
12588
12589
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 playerscripts[4] = new script_data();
12590 }
12591
3/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 74 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
96 if(s_version > 8 && s_version < 10)
12592 {
12593
12594 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12595 {
12596 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &ewpnscripts[i], zmeta_version);
12597
12598 if(ret != 0) return qe_invalid;
12599 }
12600 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12601 {
12602 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &dmapscripts[i], zmeta_version);
12603
12604 if(ret != 0) return qe_invalid;
12605 }
12606
12607 }
12608
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 22 times.
96 if(s_version >= 10)
12609 {
12610
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 22 times.
5654 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12611 {
12612 5632 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &lwpnscripts[i], zmeta_version);
12613
12614
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(ret != 0) return qe_invalid;
12615 5632 }
12616
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 22 times.
5654 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12617 {
12618 5632 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &ewpnscripts[i], zmeta_version);
12619
12620
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(ret != 0) return qe_invalid;
12621 5632 }
12622
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 22 times.
5654 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12623 {
12624 5632 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &dmapscripts[i], zmeta_version);
12625
12626
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(ret != 0) return qe_invalid;
12627 5632 }
12628
12629 22 }
12630
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 22 times.
96 if(s_version >=12)
12631 {
12632
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 22 times.
5654 for(int32_t i = 0; i < NUMSCRIPTSITEMSPRITE; i++)
12633 {
12634 5632 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &itemspritescripts[i], zmeta_version);
12635
12636
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(ret != 0) return qe_invalid;
12637 5632 }
12638 22 }
12639
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 22 times.
96 if(s_version >=15)
12640 {
12641
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 22 times.
11286 for(int32_t i = 0; i < NUMSCRIPTSCOMBODATA; i++)
12642 {
12643 11264 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &comboscripts[i], zmeta_version);
12644
12645
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(ret != 0) return qe_invalid;
12646 11264 }
12647 22 }
12648
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 22 times.
96 if(s_version >19)
12649 {
12650 22 word numgenscripts = NUMSCRIPTSGENERIC;
12651
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(!p_igetw(&numgenscripts,f,true))
12652 {
12653 return qe_invalid;
12654 }
12655
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 22 times.
11286 for(int32_t i = 0; i < numgenscripts; i++)
12656 {
12657 11264 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &genericscripts[i], zmeta_version);
12658
12659
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(ret != 0) return qe_invalid;
12660 11264 }
12661 22 }
12662
12663 /*
12664 else //Is this trip really necessary?
12665 {
12666 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12667 {
12668
12669 ewpnscripts[i] = NULL;
12670 }
12671 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12672 {
12673 dmapscripts[i] = NULL;
12674 }
12675 }
12676 */
12677
12678 96 }
12679
12680
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(s_version > 2)
12681 {
12682 int32_t bufsize;
12683 96 p_igetl(&bufsize, f, true);
12684 96 char * buf = new char[bufsize+1];
12685 96 pfread(buf, bufsize, f, true);
12686 96 buf[bufsize]=0;
12687
12688
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(keepdata)
12689
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 zScript = string(buf);
12690
12691
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 delete[] buf;
12692 word numffcbindings;
12693 96 p_igetw(&numffcbindings, f, true);
12694
12695
2/2
✓ Branch 0 taken 970 times.
✓ Branch 1 taken 96 times.
1066 for(int32_t i=0; i<numffcbindings; i++)
12696 {
12697 word id;
12698 970 p_igetw(&id, f, true);
12699 970 p_igetl(&bufsize, f, true);
12700 970 buf = new char[bufsize+1];
12701 970 pfread(buf, bufsize, f, true);
12702 970 buf[bufsize]=0;
12703
12704 //fix for buggy older saved quests -DD
12705
2/4
✓ Branch 0 taken 970 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 970 times.
970 if(keepdata && id < NUMSCRIPTFFC-1)
12706 970 ffcmap[id].scriptname = buf;
12707
12708
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 970 times.
970 delete[] buf;
12709 970 }
12710
12711 word numglobalbindings;
12712 96 p_igetw(&numglobalbindings, f, true);
12713
12714
2/2
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 96 times.
494 for(int32_t i=0; i<numglobalbindings; i++)
12715 {
12716 word id;
12717 398 p_igetw(&id, f, true);
12718 398 p_igetl(&bufsize, f, true);
12719 398 buf = new char[bufsize+1];
12720 398 pfread(buf, bufsize, f, true);
12721 398 buf[bufsize]=0;
12722
12723 // id in principle should be valid, since slot assignment cannot assign a global script to a bogus slot.
12724 // However, because of a corruption bug, some 2.50.x quests contain bogus entries in the global bindings table.
12725 // Ignore these. -DD
12726
4/6
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 398 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 159 times.
✓ Branch 5 taken 239 times.
398 if(keepdata && id >= 0 && id < NUMSCRIPTGLOBAL)
12727 {
12728 //Disable old '~Continue's, they'd wreak havoc. Bit messy, apologies ~Joe
12729
1/2
✓ Branch 0 taken 239 times.
✗ Branch 1 not taken.
239 if(strcmp(buf,"~Continue") == 0)
12730 {
12731 globalmap[id].scriptname = "";
12732
12733 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12734 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD]->disable();
12735 }
12736 else
12737 {
12738 239 globalmap[id].scriptname = buf;
12739 }
12740 239 }
12741
12742
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 delete[] buf;
12743 398 }
12744
12745
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(s_version > 3)
12746 {
12747 word numitembindings;
12748 96 p_igetw(&numitembindings, f, true);
12749
12750
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 96 times.
177 for(int32_t i=0; i<numitembindings; i++)
12751 {
12752 word id;
12753 81 p_igetw(&id, f, true);
12754 81 p_igetl(&bufsize, f, true);
12755 81 buf = new char[bufsize+1];
12756 81 pfread(buf, bufsize, f, true);
12757 81 buf[bufsize]=0;
12758
12759 //fix this too
12760
2/4
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 81 times.
81 if(keepdata && id <NUMSCRIPTITEM-1)
12761 81 itemmap[id].scriptname = buf;
12762
12763
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81 times.
81 delete[] buf;
12764 81 }
12765 96 }
12766 //(v9+)
12767
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 22 times.
96 if(s_version > 8)
12768 {
12769 //npc scripts
12770 word numnpcbindings;
12771 22 p_igetw(&numnpcbindings, f, true);
12772
12773
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 22 times.
34 for(int32_t i=0; i<numnpcbindings; i++)
12774 {
12775 word id;
12776 12 p_igetw(&id, f, true);
12777 12 p_igetl(&bufsize, f, true);
12778 12 buf = new char[bufsize+1];
12779 12 pfread(buf, bufsize, f, true);
12780 12 buf[bufsize]=0;
12781
12782 //fix this too
12783
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
12 if(keepdata && id <NUMSCRIPTGUYS-1)
12784 12 npcmap[id].scriptname = buf;
12785
12786
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 delete[] buf;
12787 12 }
12788 //lweapon
12789 word numlwpnbindings;
12790 22 p_igetw(&numlwpnbindings, f, true);
12791
12792
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 22 times.
64 for(int32_t i=0; i<numlwpnbindings; i++)
12793 {
12794 word id;
12795 42 p_igetw(&id, f, true);
12796 42 p_igetl(&bufsize, f, true);
12797 42 buf = new char[bufsize+1];
12798 42 pfread(buf, bufsize, f, true);
12799 42 buf[bufsize]=0;
12800
12801 //fix this too
12802
2/4
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 42 times.
42 if(keepdata && id <NUMSCRIPTWEAPONS-1)
12803 42 lwpnmap[id].scriptname = buf;
12804
12805
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 delete[] buf;
12806 42 }
12807 //eweapon
12808 word numewpnbindings;
12809 22 p_igetw(&numewpnbindings, f, true);
12810
12811
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 22 times.
85 for(int32_t i=0; i<numewpnbindings; i++)
12812 {
12813 word id;
12814 63 p_igetw(&id, f, true);
12815 63 p_igetl(&bufsize, f, true);
12816 63 buf = new char[bufsize+1];
12817 63 pfread(buf, bufsize, f, true);
12818 63 buf[bufsize]=0;
12819
12820 //fix this too
12821
2/4
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 63 times.
63 if(keepdata && id <NUMSCRIPTWEAPONS-1)
12822 63 ewpnmap[id].scriptname = buf;
12823
12824
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 delete[] buf;
12825 63 }
12826 //hero
12827 word numherobindings;
12828 22 p_igetw(&numherobindings, f, true);
12829
12830
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 22 times.
26 for(int32_t i=0; i<numherobindings; i++)
12831 {
12832 word id;
12833 4 p_igetw(&id, f, true);
12834 4 p_igetl(&bufsize, f, true);
12835 4 buf = new char[bufsize+1];
12836 4 pfread(buf, bufsize, f, true);
12837 4 buf[bufsize]=0;
12838
12839 //fix this too
12840
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
4 if(keepdata && id <NUMSCRIPTPLAYER-1)
12841 4 playermap[id].scriptname = buf;
12842
12843
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 delete[] buf;
12844 4 }
12845 //dmaps
12846 word numdmapbindings;
12847 22 p_igetw(&numdmapbindings, f, true);
12848
12849
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 22 times.
36 for(int32_t i=0; i<numdmapbindings; i++)
12850 {
12851 word id;
12852 14 p_igetw(&id, f, true);
12853 14 p_igetl(&bufsize, f, true);
12854 14 buf = new char[bufsize+1];
12855 14 pfread(buf, bufsize, f, true);
12856 14 buf[bufsize]=0;
12857
12858 //fix this too
12859
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
14 if(keepdata && id <NUMSCRIPTSDMAP-1)
12860 14 dmapmap[id].scriptname = buf;
12861
12862
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 delete[] buf;
12863 14 }
12864 //screen
12865 word numscreenbindings;
12866 22 p_igetw(&numscreenbindings, f, true);
12867
12868
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 22 times.
33 for(int32_t i=0; i<numscreenbindings; i++)
12869 {
12870 word id;
12871 11 p_igetw(&id, f, true);
12872 11 p_igetl(&bufsize, f, true);
12873 11 buf = new char[bufsize+1];
12874 11 pfread(buf, bufsize, f, true);
12875 11 buf[bufsize]=0;
12876
12877 //fix this too
12878
2/4
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11 times.
11 if(keepdata && id <NUMSCRIPTSDMAP-1)
12879 11 screenmap[id].scriptname = buf;
12880
12881
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 delete[] buf;
12882 11 }
12883 22 }
12884
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 22 times.
96 if(s_version > 11)
12885 {
12886 word numspritebindings;
12887 22 p_igetw(&numspritebindings, f, true);
12888
12889
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 22 times.
32 for(int32_t i=0; i<numspritebindings; i++)
12890 {
12891 word id;
12892 10 p_igetw(&id, f, true);
12893 10 p_igetl(&bufsize, f, true);
12894 10 buf = new char[bufsize+1];
12895 10 pfread(buf, bufsize, f, true);
12896 10 buf[bufsize]=0;
12897
12898 //fix this too
12899
2/4
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10 times.
10 if(keepdata && id <NUMSCRIPTSDMAP-1)
12900 10 itemspritemap[id].scriptname = buf;
12901
12902
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 delete[] buf;
12903 10 }
12904 22 }
12905
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 22 times.
96 if(s_version >= 15)
12906 {
12907 word numcombobindings;
12908 22 p_igetw(&numcombobindings, f, true);
12909
12910
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 22 times.
46 for(int32_t i=0; i<numcombobindings; i++)
12911 {
12912 word id;
12913 24 p_igetw(&id, f, true);
12914 24 p_igetl(&bufsize, f, true);
12915 24 buf = new char[bufsize+1];
12916 24 pfread(buf, bufsize, f, true);
12917 24 buf[bufsize]=0;
12918
12919 //fix this too
12920
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
24 if(keepdata && id <NUMSCRIPTSCOMBODATA-1)
12921 24 comboscriptmap[id].scriptname = buf;
12922
12923
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 delete[] buf;
12924 24 }
12925 22 }
12926
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 22 times.
96 if(s_version > 19)
12927 {
12928 word numgenericbindings;
12929 22 p_igetw(&numgenericbindings, f, true);
12930
12931
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 22 times.
36 for(int32_t i=0; i<numgenericbindings; i++)
12932 {
12933 word id;
12934 14 p_igetw(&id, f, true);
12935 14 p_igetl(&bufsize, f, true);
12936 14 buf = new char[bufsize+1];
12937 14 pfread(buf, bufsize, f, true);
12938 14 buf[bufsize]=0;
12939
12940 //fix this too
12941
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
14 if(keepdata && id <NUMSCRIPTSGENERIC-1)
12942 14 genericmap[id].scriptname = buf;
12943
12944
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 delete[] buf;
12945 14 }
12946 22 }
12947 96 }
12948
12949 96 return 0;
12950 96 }
12951
12952 99 void reset_scripts()
12953 {
12954 //OK, who spaced this? ;)
12955
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 99 times.
50787 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
12956 {
12957
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 50688 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 50688 times.
50688 if(ffscripts[i]!=NULL) delete ffscripts[i];
12958 50688 }
12959
12960
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
12961 {
12962
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 25344 times.
25344 if(itemscripts[i]!=NULL) delete itemscripts[i];
12963 25344 }
12964
12965
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
12966 {
12967
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 25344 times.
25344 if(guyscripts[i]!=NULL) delete guyscripts[i];
12968 25344 }
12969
12970
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12971 {
12972
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 25344 times.
25344 if(wpnscripts[i]!=NULL) delete wpnscripts[i];
12973 25344 }
12974
12975
12976
12977
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
12978 {
12979
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 25344 times.
25344 if(screenscripts[i]!=NULL) delete screenscripts[i];
12980 25344 }
12981
12982
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 99 times.
891 for(int32_t i=0; i<NUMSCRIPTGLOBAL; i++)
12983 {
12984
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 792 times.
792 if(globalscripts[i]!=NULL) delete globalscripts[i];
12985 792 }
12986
12987
2/2
✓ Branch 0 taken 495 times.
✓ Branch 1 taken 99 times.
594 for(int32_t i=0; i<NUMSCRIPTPLAYER; i++)
12988 {
12989
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 495 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 495 times.
495 if(playerscripts[i]!=NULL) delete playerscripts[i];
12990 495 }
12991
12992
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12993 {
12994
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 25344 times.
25344 if(lwpnscripts[i]!=NULL) delete lwpnscripts[i];
12995 25344 }
12996
12997
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12998 {
12999
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 25344 times.
25344 if(ewpnscripts[i]!=NULL) delete ewpnscripts[i];
13000 25344 }
13001
13002
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
13003 {
13004
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 25344 times.
25344 if(dmapscripts[i]!=NULL) delete dmapscripts[i];
13005 25344 }
13006
13007
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
13008 {
13009
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 25344 times.
25344 if(itemspritescripts[i]!=NULL) delete itemspritescripts[i];
13010 25344 }
13011
13012
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 99 times.
50787 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
13013 {
13014
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 50688 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 50688 times.
50688 if(comboscripts[i]!=NULL) delete comboscripts[i];
13015 50688 }
13016
13017 99 next_script_data_debug_id = 0;
13018
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 99 times.
50787 for(int32_t i=0; i<NUMSCRIPTSGENERIC; i++)
13019 {
13020
3/4
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 35840 times.
✓ Branch 2 taken 35840 times.
✗ Branch 3 not taken.
50688 if(genericscripts[i]!=NULL) delete genericscripts[i];
13021
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 genericscripts[i] = new script_data();
13022 50688 }
13023
13024
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 99 times.
50787 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
13025 {
13026
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 ffscripts[i] = new script_data();
13027 50688 }
13028
13029
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
13030 {
13031
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 itemscripts[i] = new script_data();
13032 25344 }
13033
13034
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
13035 {
13036
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 guyscripts[i] = new script_data();
13037 25344 }
13038
13039
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13040 {
13041
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 wpnscripts[i] = new script_data();
13042 25344 }
13043
13044
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
13045 {
13046
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 screenscripts[i] = new script_data();
13047 25344 }
13048
13049
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 99 times.
891 for(int32_t i=0; i<NUMSCRIPTGLOBAL; i++)
13050 {
13051
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 globalscripts[i] = new script_data();
13052 792 }
13053
13054
2/2
✓ Branch 0 taken 495 times.
✓ Branch 1 taken 99 times.
594 for(int32_t i=0; i<NUMSCRIPTPLAYER; i++)
13055 {
13056
1/2
✓ Branch 0 taken 495 times.
✗ Branch 1 not taken.
495 playerscripts[i] = new script_data();
13057 495 }
13058
13059
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13060 {
13061
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 lwpnscripts[i] = new script_data();
13062 25344 }
13063
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13064 {
13065
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 ewpnscripts[i] = new script_data();
13066 25344 }
13067
13068
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
13069 {
13070
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 dmapscripts[i] = new script_data();
13071 25344 }
13072
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
13073 {
13074
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 itemspritescripts[i] = new script_data();
13075 25344 }
13076
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 99 times.
50787 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
13077 {
13078
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 comboscripts[i] = new script_data();
13079 50688 }
13080 99 }
13081
13082 extern script_command command_list[];
13083 193316 int32_t read_one_ffscript(PACKFILE *f, zquestheader *, bool keepdata, int32_t , word s_version, word , script_data **script, word zmeta_version)
13084 {
13085 //Please also update loadquest() when modifying this method -DD
13086 193316 char b33[34] = {0};
13087 193316 b33[33] = 0;
13088 193316 ffscript temp_script;
13089 193316 int32_t num_commands=1000;
13090
13091
1/2
✓ Branch 0 taken 193316 times.
✗ Branch 1 not taken.
193316 if(s_version>=2)
13092 {
13093
2/4
✓ Branch 0 taken 193316 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193316 times.
✗ Branch 3 not taken.
193316 if(!p_igetl(&num_commands,f,true))
13094 {
13095 return qe_invalid;
13096 }
13097 193316 }
13098
13099
1/2
✓ Branch 0 taken 193316 times.
✗ Branch 1 not taken.
193316 if(keepdata)
13100 {
13101
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 193316 times.
193316 if((*script) != NULL) //Surely we want to do this regardless of keepdata? //No, we don't -V
13102
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 193316 times.
193316 delete (*script);
13103
2/4
✓ Branch 0 taken 193316 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193316 times.
✗ Branch 3 not taken.
193316 (*script) = new script_data(num_commands);
13104 193316 }
13105
2/2
✓ Branch 0 taken 79134 times.
✓ Branch 1 taken 114182 times.
193316 if(s_version >= 16)
13106 {
13107
1/2
✓ Branch 0 taken 79134 times.
✗ Branch 1 not taken.
79134 zasm_meta temp_meta;
13108
13109
2/4
✓ Branch 0 taken 79134 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 79134 times.
✗ Branch 3 not taken.
79134 if(!p_igetw(&(temp_meta.zasm_v),f,true))
13110 {
13111 return qe_invalid;
13112 }
13113
13114
2/4
✓ Branch 0 taken 79134 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 79134 times.
✗ Branch 3 not taken.
79134 if(!p_igetw(&(temp_meta.meta_v),f,true))
13115 {
13116 return qe_invalid;
13117 }
13118
13119
2/4
✓ Branch 0 taken 79134 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 79134 times.
✗ Branch 3 not taken.
79134 if(!p_igetw(&(temp_meta.ffscript_v),f,true))
13120 {
13121 return qe_invalid;
13122 }
13123
13124
2/4
✓ Branch 0 taken 79134 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 79134 times.
✗ Branch 3 not taken.
79134 if(!p_getc(&(temp_meta.script_type),f,true))
13125 {
13126 return qe_invalid;
13127 }
13128
13129
2/2
✓ Branch 0 taken 633072 times.
✓ Branch 1 taken 79134 times.
712206 for(int32_t q = 0; q < 8; ++q)
13130 {
13131
2/2
✓ Branch 0 taken 201432 times.
✓ Branch 1 taken 431640 times.
633072 if(zmeta_version < 3)
13132 {
13133
2/2
✓ Branch 0 taken 201432 times.
✓ Branch 1 taken 6647256 times.
6848688 for(int32_t c = 0; c < 33; ++c)
13134 {
13135
2/4
✓ Branch 0 taken 6647256 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6647256 times.
✗ Branch 3 not taken.
6647256 if(!p_getc(&(b33[c]),f,true))
13136 {
13137 return qe_invalid;
13138 }
13139 6647256 }
13140
1/2
✓ Branch 0 taken 201432 times.
✗ Branch 1 not taken.
201432 temp_meta.run_idens[q].assign(b33);
13141 201432 }
13142 else
13143 {
13144
2/4
✓ Branch 0 taken 431640 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 431640 times.
✗ Branch 3 not taken.
431640 if(!p_getcstr(&temp_meta.run_idens[q],f,true))
13145 {
13146 return qe_invalid;
13147 }
13148 }
13149 633072 }
13150
13151
2/2
✓ Branch 0 taken 79134 times.
✓ Branch 1 taken 633072 times.
712206 for(int32_t q = 0; q < 8; ++q)
13152 {
13153
2/4
✓ Branch 0 taken 633072 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 633072 times.
✗ Branch 3 not taken.
633072 if(!p_getc(&(temp_meta.run_types[q]),f,true))
13154 {
13155 return qe_invalid;
13156 }
13157 633072 }
13158
13159
2/4
✓ Branch 0 taken 79134 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 79134 times.
✗ Branch 3 not taken.
79134 if(!p_getc(&(temp_meta.flags),f,true))
13160 {
13161 return qe_invalid;
13162 }
13163
13164
2/4
✓ Branch 0 taken 79134 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 79134 times.
✗ Branch 3 not taken.
79134 if(!p_igetw(&(temp_meta.compiler_v1),f,true))
13165 {
13166 return qe_invalid;
13167 }
13168
13169
2/4
✓ Branch 0 taken 79134 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 79134 times.
✗ Branch 3 not taken.
79134 if(!p_igetw(&(temp_meta.compiler_v2),f,true))
13170 {
13171 return qe_invalid;
13172 }
13173
13174
2/4
✓ Branch 0 taken 79134 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 79134 times.
✗ Branch 3 not taken.
79134 if(!p_igetw(&(temp_meta.compiler_v3),f,true))
13175 {
13176 return qe_invalid;
13177 }
13178
13179
2/4
✓ Branch 0 taken 79134 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 79134 times.
✗ Branch 3 not taken.
79134 if(!p_igetw(&(temp_meta.compiler_v4),f,true))
13180 {
13181 return qe_invalid;
13182 }
13183
13184
2/2
✓ Branch 0 taken 25179 times.
✓ Branch 1 taken 53955 times.
79134 if(zmeta_version == 2)
13185 {
13186
2/2
✓ Branch 0 taken 25179 times.
✓ Branch 1 taken 830907 times.
856086 for(int32_t c = 0; c < 33; ++c)
13187 {
13188
2/4
✓ Branch 0 taken 830907 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 830907 times.
✗ Branch 3 not taken.
830907 if(!p_getc(&b33[c],f,true))
13189 {
13190 return qe_invalid;
13191 }
13192 830907 }
13193
1/2
✓ Branch 0 taken 25179 times.
✗ Branch 1 not taken.
25179 temp_meta.script_name.assign(b33);
13194
13195
2/2
✓ Branch 0 taken 25179 times.
✓ Branch 1 taken 830907 times.
856086 for(int32_t c = 0; c < 33; ++c)
13196 {
13197
2/4
✓ Branch 0 taken 830907 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 830907 times.
✗ Branch 3 not taken.
830907 if(!p_getc(&b33[c],f,true))
13198 {
13199 return qe_invalid;
13200 }
13201 830907 }
13202
1/2
✓ Branch 0 taken 25179 times.
✗ Branch 1 not taken.
25179 temp_meta.author.assign(b33);
13203 25179 }
13204
1/2
✓ Branch 0 taken 53955 times.
✗ Branch 1 not taken.
53955 else if(zmeta_version > 2)
13205 {
13206
2/4
✓ Branch 0 taken 53955 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 53955 times.
✗ Branch 3 not taken.
53955 if(!p_getcstr(&temp_meta.script_name,f,true))
13207 return qe_invalid;
13208
2/4
✓ Branch 0 taken 53955 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 53955 times.
✗ Branch 3 not taken.
53955 if(!p_getcstr(&temp_meta.author,f,true))
13209 return qe_invalid;
13210 53955 auto num_meta_attrib = (zmeta_version < 5 ? 4 : 10);
13211
2/2
✓ Branch 0 taken 539550 times.
✓ Branch 1 taken 53955 times.
593505 for(auto q = 0; q < num_meta_attrib; ++q)
13212 {
13213
2/4
✓ Branch 0 taken 539550 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 539550 times.
✗ Branch 3 not taken.
539550 if(!p_getcstr(&temp_meta.attributes[q],f,true))
13214 return qe_invalid;
13215
2/4
✓ Branch 0 taken 539550 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 539550 times.
✗ Branch 3 not taken.
539550 if(!p_getwstr(&temp_meta.attributes_help[q],f,true))
13216 return qe_invalid;
13217 539550 }
13218
2/2
✓ Branch 0 taken 431640 times.
✓ Branch 1 taken 53955 times.
485595 for(auto q = 0; q < 8; ++q)
13219 {
13220
2/4
✓ Branch 0 taken 431640 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 431640 times.
✗ Branch 3 not taken.
431640 if(!p_getcstr(&temp_meta.attribytes[q],f,true))
13221 return qe_invalid;
13222
2/4
✓ Branch 0 taken 431640 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 431640 times.
✗ Branch 3 not taken.
431640 if(!p_getwstr(&temp_meta.attribytes_help[q],f,true))
13223 return qe_invalid;
13224 431640 }
13225
2/2
✓ Branch 0 taken 431640 times.
✓ Branch 1 taken 53955 times.
485595 for(auto q = 0; q < 8; ++q)
13226 {
13227
2/4
✓ Branch 0 taken 431640 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 431640 times.
✗ Branch 3 not taken.
431640 if(!p_getcstr(&temp_meta.attrishorts[q],f,true))
13228 return qe_invalid;
13229
2/4
✓ Branch 0 taken 431640 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 431640 times.
✗ Branch 3 not taken.
431640 if(!p_getwstr(&temp_meta.attrishorts_help[q],f,true))
13230 return qe_invalid;
13231 431640 }
13232
2/2
✓ Branch 0 taken 863280 times.
✓ Branch 1 taken 53955 times.
917235 for(auto q = 0; q < 16; ++q)
13233 {
13234
2/4
✓ Branch 0 taken 863280 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 863280 times.
✗ Branch 3 not taken.
863280 if(!p_getcstr(&temp_meta.usrflags[q],f,true))
13235 return qe_invalid;
13236
2/4
✓ Branch 0 taken 863280 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 863280 times.
✗ Branch 3 not taken.
863280 if(!p_getwstr(&temp_meta.usrflags_help[q],f,true))
13237 return qe_invalid;
13238 863280 }
13239 53955 }
13240
2/2
✓ Branch 0 taken 53955 times.
✓ Branch 1 taken 25179 times.
79134 if(zmeta_version > 3)
13241 {
13242
2/2
✓ Branch 0 taken 431640 times.
✓ Branch 1 taken 53955 times.
485595 for(auto q = 0; q < 8; ++q)
13243 {
13244
2/4
✓ Branch 0 taken 431640 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 431640 times.
✗ Branch 3 not taken.
431640 if(!p_getcstr(&temp_meta.initd[q],f,true))
13245 return qe_invalid;
13246
2/4
✓ Branch 0 taken 431640 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 431640 times.
✗ Branch 3 not taken.
431640 if(!p_getwstr(&temp_meta.initd_help[q],f,true))
13247 return qe_invalid;
13248 431640 }
13249
2/2
✓ Branch 0 taken 431640 times.
✓ Branch 1 taken 53955 times.
485595 for(auto q = 0; q < 8; ++q)
13250 {
13251
2/4
✓ Branch 0 taken 431640 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 431640 times.
✗ Branch 3 not taken.
431640 if(!p_getc(&temp_meta.initd_type[q],f,true))
13252 return qe_invalid;
13253 431640 }
13254 53955 }
13255 else
13256 {
13257
2/2
✓ Branch 0 taken 201432 times.
✓ Branch 1 taken 25179 times.
226611 for(auto q = 0; q < 8; ++q)
13258 {
13259
1/2
✓ Branch 0 taken 201432 times.
✗ Branch 1 not taken.
201432 temp_meta.initd[q] = temp_meta.run_idens[q];
13260 201432 }
13261 }
13262
13263
1/2
✓ Branch 0 taken 79134 times.
✗ Branch 1 not taken.
79134 if(keepdata)
13264
1/2
✓ Branch 0 taken 79134 times.
✗ Branch 1 not taken.
79134 (*script)->meta = temp_meta;
13265
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79134 times.
79134 }
13266
13267
1/2
✓ Branch 0 taken 193316 times.
✗ Branch 1 not taken.
193316 temp_script.clear();
13268
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7767709 times.
7767709 for(int32_t j=0; j<num_commands; j++)
13269 {
13270
2/4
✓ Branch 0 taken 7767709 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7767709 times.
✗ Branch 3 not taken.
7767709 if(!p_igetw(&(temp_script.command),f,true))
13271 {
13272 return qe_invalid;
13273 }
13274
13275
2/2
✓ Branch 0 taken 7574393 times.
✓ Branch 1 taken 193316 times.
7767709 if(temp_script.command == 0xFFFF)
13276 {
13277
1/2
✓ Branch 0 taken 193316 times.
✗ Branch 1 not taken.
193316 if(keepdata)
13278
1/2
✓ Branch 0 taken 193316 times.
✗ Branch 1 not taken.
193316 (*script)->zasm[j].clear();
13279 193316 break;
13280 }
13281 else
13282 {
13283
2/4
✓ Branch 0 taken 7574393 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7574393 times.
✗ Branch 3 not taken.
7574393 if(!p_igetl(&(temp_script.arg1),f,keepdata))
13284 {
13285 return qe_invalid;
13286 }
13287
13288
2/4
✓ Branch 0 taken 7574393 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7574393 times.
✗ Branch 3 not taken.
7574393 if(!p_igetl(&(temp_script.arg2),f,keepdata))
13289 {
13290 return qe_invalid;
13291 }
13292
13293
2/2
✓ Branch 0 taken 451725 times.
✓ Branch 1 taken 7122668 times.
7574393 if(s_version >= 21)
13294 {
13295 451725 uint32_t sz = 0;
13296
2/4
✓ Branch 0 taken 451725 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 451725 times.
✗ Branch 3 not taken.
451725 if(!p_igetl(&sz,f,keepdata))
13297 {
13298 return qe_invalid;
13299 }
13300
2/2
✓ Branch 0 taken 1522 times.
✓ Branch 1 taken 450203 times.
451725 if(sz) //string found
13301 {
13302
1/2
✓ Branch 0 taken 1522 times.
✗ Branch 1 not taken.
1522 temp_script.strptr = new std::string();
13303 char dummy;
13304
2/2
✓ Branch 0 taken 115152 times.
✓ Branch 1 taken 1522 times.
116674 for(size_t q = 0; q < sz; ++q)
13305 {
13306
2/4
✓ Branch 0 taken 115152 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115152 times.
✗ Branch 3 not taken.
115152 if(!p_getc(&dummy,f,keepdata))
13307 {
13308 return qe_invalid;
13309 }
13310
1/2
✓ Branch 0 taken 115152 times.
✗ Branch 1 not taken.
115152 temp_script.strptr->push_back(dummy);
13311 115152 }
13312 1522 }
13313
2/4
✓ Branch 0 taken 451725 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 451725 times.
✗ Branch 3 not taken.
451725 if(!p_igetl(&sz,f,keepdata))
13314 {
13315 return qe_invalid;
13316 }
13317
2/2
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 451635 times.
451725 if(sz) //vector found
13318 {
13319
1/2
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
90 temp_script.vecptr = new std::vector<int32_t>();
13320 int32_t dummy;
13321
2/2
✓ Branch 0 taken 1311 times.
✓ Branch 1 taken 90 times.
1401 for(size_t q = 0; q < sz; ++q)
13322 {
13323
2/4
✓ Branch 0 taken 1311 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1311 times.
✗ Branch 3 not taken.
1311 if(!p_igetl(&dummy,f,keepdata))
13324 {
13325 return qe_invalid;
13326 }
13327
1/2
✓ Branch 0 taken 1311 times.
✗ Branch 1 not taken.
1311 temp_script.vecptr->push_back(dummy);
13328 1311 }
13329 90 }
13330 451725 }
13331
13332
1/2
✓ Branch 0 taken 7574393 times.
✗ Branch 1 not taken.
7574393 if(keepdata)
13333 {
13334
1/2
✓ Branch 0 taken 7574393 times.
✗ Branch 1 not taken.
7574393 temp_script.give((*script)->zasm[j]);
13335 7574393 }
13336 }
13337
1/2
✓ Branch 0 taken 7574393 times.
✗ Branch 1 not taken.
7574393 temp_script.clear();
13338 7574393 }
13339
13340 193316 return 0;
13341 193316 }
13342
13343 extern SAMPLE customsfxdata[WAV_COUNT];
13344 extern uint8_t customsfxflag[WAV_COUNT>>3];
13345 extern int32_t sfxdat;
13346 extern DATAFILE *sfxdata;
13347 const char *old_sfx_string[Z35] =
13348 {
13349 "Arrow", "Sword beam", "Bomb blast", "Boomerang", "Subscreen cursor",
13350 "Shield is hit", "Item chime", "Roar (Dodongo, Gohma)", "Shutter", "Enemy dies",
13351 "Enemy is hit", "Low hearts warning", "Fire", "Ganon's fanfare", "Boss is hit", "Hammer",
13352 "Hookshot", "Message", "Player is hit", "Item fanfare", "Bomb placed", "Item pickup",
13353 "Refill", "Roar (Aquamentus, Gleeok, Ganon)", "Item pickup 2", "Ocean ambience",
13354 "Secret chime", "Player dies", "Stairs", "Sword", "Roar (Manhandla, Digdogger, Patra)",
13355 "Wand magic", "Whistle", "Zelda's fanfare", "Charging weapon", "Charging weapon 2",
13356 "Din's Fire", "Enemy falls from ceiling", "Farore's Wind", "Fireball", "Tall Grass slashed",
13357 "Pound pounded", "Hover Boots", "Ice magic", "Jump", "Lens of Truth off", "Lens of Truth on",
13358 "Nayru's Love shield", "Nayru's Love shield 2", "Push block", "Rock", "Spell rocket down",
13359 "Spell rocket up", "Sword spin attack", "Splash", "Summon magic", "Sword tapping",
13360 "Sword tapping (secret)", "Whistle whirlwind", "Cane of Byrna orbit"
13361 };
13362 char *sfx_string[WAV_COUNT];
13363
13364 96 int32_t readsfx(PACKFILE *f, zquestheader *Header, bool keepdata)
13365 {
13366 //these are here to bypass compiler warnings about unused arguments
13367 96 Header=Header;
13368
13369 int32_t dummy;
13370 96 word s_version=0, s_cversion=0;
13371 //int32_t ret;
13372 SAMPLE temp_sample;
13373 96 temp_sample.loop_start=0;
13374 96 temp_sample.loop_end=0;
13375 96 temp_sample.param=0;
13376
13377 //section version info
13378
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_igetw(&s_version,f,true))
13379 {
13380 return qe_invalid;
13381 }
13382
13383 96 FFCore.quest_format[vSFX] = s_version;
13384
13385 //al_trace("SFX version %d\n", s_version);
13386
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetw(&s_cversion,f,true))
13387 {
13388 return qe_invalid;
13389 }
13390
13391 //section size
13392
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&dummy,f,true))
13393 {
13394 return qe_invalid;
13395 }
13396
13397 /* HIGHLY UNORTHODOX UPDATING THING, by L
13398 * This fixes quests made before revision 411 (such as the 'Lost Isle Build'),
13399 * where the meaning of GOTOLESS changed. It also coincided with V_SFX
13400 * changing from 1 to 2.
13401 */
13402
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
96 if(s_version < 2 && keepdata)
13403 set_bit(quest_rules,qr_GOTOLESSNOTEQUAL,1);
13404
13405 /* End highly unorthodox updating thing */
13406
13407 96 int32_t wavcount = WAV_COUNT;
13408
13409
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(s_version < 6)
13410 wavcount = 128;
13411
13412 uint8_t tempflag[WAV_COUNT>>3];
13413
13414
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(s_version < 4)
13415 {
13416 memset(tempflag, 0xFF, WAV_COUNT>>3);
13417 }
13418 else
13419 {
13420
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(s_version < 6)
13421 memset(tempflag, 0, WAV_COUNT>>3);
13422
13423
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 96 times.
3168 for(int32_t i=0; i<(wavcount>>3); i++)
13424 {
13425 3072 p_getc(&tempflag[i], f, true);
13426 3072 }
13427
13428 }
13429
13430
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(s_version>4)
13431 {
13432
2/2
✓ Branch 0 taken 24480 times.
✓ Branch 1 taken 96 times.
24576 for(int32_t i=1; i<WAV_COUNT; i++)
13433 {
13434
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24480 times.
24480 if(keepdata)
13435 {
13436 24480 sprintf(sfx_string[i],"s%03d",i);
13437
13438
2/2
✓ Branch 0 taken 18720 times.
✓ Branch 1 taken 5760 times.
24480 if((i<Z35))
13439 5760 strcpy(sfx_string[i], old_sfx_string[i-1]);
13440 24480 }
13441
13442
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24480 times.
24480 if(i>=wavcount)
13443 continue;
13444
2/2
✓ Branch 0 taken 1835 times.
✓ Branch 1 taken 22645 times.
24480 if(get_bit(tempflag, i-1))
13445 {
13446 char tempname[36];
13447
13448
1/2
✓ Branch 0 taken 1835 times.
✗ Branch 1 not taken.
1835 if(!pfread(tempname, 36, f, keepdata))
13449 {
13450 return qe_invalid;
13451 }
13452
13453
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1835 times.
1835 if(keepdata)
13454 {
13455 1835 strcpy(sfx_string[i], tempname);
13456 1835 sfx_string[i][35] = 0; //Force NULL Termination
13457 1835 }
13458 1835 }
13459
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22645 times.
22645 else if(keepdata)
13460 {
13461 22645 sprintf(sfx_string[i],"s%03d",i);
13462
13463
2/2
✓ Branch 0 taken 18224 times.
✓ Branch 1 taken 4421 times.
22645 if(i<Z35)
13464 4421 strcpy(sfx_string[i], old_sfx_string[i-1]);
13465 22645 sfx_string[i][35] = 0; //Force NULL Termination
13466 22645 }
13467 24480 }
13468 96 }
13469 else
13470 {
13471 if(keepdata)
13472 {
13473 for(int32_t i=1; i<WAV_COUNT; i++)
13474 {
13475 sprintf(sfx_string[i],"s%03d",i);
13476
13477 if(i<Z35)
13478 strcpy(sfx_string[i], old_sfx_string[i-1]);
13479 }
13480 }
13481 }
13482
13483 //finally... section data
13484
2/2
✓ Branch 0 taken 24480 times.
✓ Branch 1 taken 96 times.
24576 for(int32_t i=1; i<wavcount; i++)
13485 {
13486
2/2
✓ Branch 0 taken 1835 times.
✓ Branch 1 taken 22645 times.
24480 if(get_bit(tempflag, i-1))
13487 {
13488
13489
1/2
✓ Branch 0 taken 1835 times.
✗ Branch 1 not taken.
1835 if(!p_igetl(&dummy,f,true))
13490 {
13491 return qe_invalid;
13492 }
13493
13494 1835 (temp_sample.bits) = dummy;
13495
13496
1/2
✓ Branch 0 taken 1835 times.
✗ Branch 1 not taken.
1835 if(!p_igetl(&dummy,f,true))
13497 {
13498 return qe_invalid;
13499 }
13500
13501 1835 (temp_sample.stereo) = dummy;
13502
13503
1/2
✓ Branch 0 taken 1835 times.
✗ Branch 1 not taken.
1835 if(!p_igetl(&dummy,f,keepdata))
13504 {
13505 return qe_invalid;
13506 }
13507
13508 1835 (temp_sample.freq) = dummy;
13509
13510
1/2
✓ Branch 0 taken 1835 times.
✗ Branch 1 not taken.
1835 if(!p_igetl(&dummy,f,keepdata))
13511 {
13512 return qe_invalid;
13513 }
13514
13515 1835 (temp_sample.priority) = dummy;
13516
13517
1/2
✓ Branch 0 taken 1835 times.
✗ Branch 1 not taken.
1835 if(!p_igetl(&(temp_sample.len),f,true))
13518 {
13519 return qe_invalid;
13520 }
13521
13522
1/2
✓ Branch 0 taken 1835 times.
✗ Branch 1 not taken.
1835 if(!p_igetl(&(temp_sample.loop_start),f,keepdata))
13523 {
13524 return qe_invalid;
13525 }
13526
13527
1/2
✓ Branch 0 taken 1835 times.
✗ Branch 1 not taken.
1835 if(!p_igetl(&(temp_sample.loop_end),f,keepdata))
13528 {
13529 return qe_invalid;
13530 }
13531
13532
1/2
✓ Branch 0 taken 1835 times.
✗ Branch 1 not taken.
1835 if(!p_igetl(&(temp_sample.param),f,keepdata))
13533 {
13534 return qe_invalid;
13535 }
13536
13537 // al_trace("F%i: L%i\n",i,temp_sample.len);
13538 // temp_sample.data = new byte[(temp_sample.bits==8?1:2)*temp_sample.len];
13539 1835 int32_t len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13540 1835 temp_sample.data = calloc(len,1);
13541
13542
1/2
✓ Branch 0 taken 1835 times.
✗ Branch 1 not taken.
1835 if(s_version < 3)
13543 len = (temp_sample.bits==8?1:2)*temp_sample.len;
13544
13545 //old-style, non-portable loading (Bad Allegro! Bad!!) -DD
13546
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1835 times.
1835 if(s_version < 2)
13547 {
13548 if(!pfread(temp_sample.data, len,f,keepdata))
13549 {
13550 return qe_invalid;
13551 }
13552 }
13553 else
13554 {
13555 //re-endianfy the data
13556 1835 int32_t wordstoread = len / sizeof(word);
13557
13558
2/2
✓ Branch 0 taken 53693862 times.
✓ Branch 1 taken 1835 times.
53695697 for(int32_t j=0; j<wordstoread; j++)
13559 {
13560 word temp;
13561
13562
1/2
✓ Branch 0 taken 53693862 times.
✗ Branch 1 not taken.
53693862 if(!p_igetw(&temp, f, keepdata))
13563 {
13564 return qe_invalid;
13565 }
13566
13567
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53693862 times.
53693862 if(keepdata)
13568 53693862 ((word *)temp_sample.data)[j] = temp;
13569 53693862 }
13570 }
13571 1835 }
13572
2/2
✓ Branch 0 taken 4421 times.
✓ Branch 1 taken 18224 times.
22645 else if(i < Z35)
13573 {
13574 4421 SAMPLE* datsamp = (SAMPLE*)(sfxdata[i].dat);
13575 4421 memcpy(&temp_sample, datsamp, sizeof(SAMPLE));
13576 4421 set_bit(tempflag, i-1, 1);
13577 4421 int32_t len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13578 4421 temp_sample.data = calloc(len,1);
13579 4421 memcpy(temp_sample.data, datsamp->data, len);
13580 4421 }
13581 18224 else continue;
13582
13583
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6256 times.
6256 if(keepdata)
13584 {
13585
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6256 times.
6256 if(customsfxdata[i].data!=NULL)
13586 {
13587 // delete [] customsfxdata[i].data;
13588 6256 free(customsfxdata[i].data);
13589 6256 }
13590
13591 // customsfxdata[i].data = new byte[(temp_sample.bits==8?1:2)*temp_sample.len];
13592 6256 int32_t len2 = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13593 6256 customsfxdata[i].data = calloc(len2,1);
13594 6256 customsfxdata[i].bits = temp_sample.bits;
13595 6256 customsfxdata[i].stereo = temp_sample.stereo;
13596 6256 customsfxdata[i].freq = temp_sample.freq;
13597 6256 customsfxdata[i].priority = temp_sample.priority;
13598 6256 customsfxdata[i].len = temp_sample.len;
13599 6256 customsfxdata[i].loop_start = temp_sample.loop_start;
13600 6256 customsfxdata[i].loop_end = temp_sample.loop_end;
13601 6256 customsfxdata[i].param = temp_sample.param;
13602 6256 int32_t cpylen = len2;
13603
13604
1/2
✓ Branch 0 taken 6256 times.
✗ Branch 1 not taken.
6256 if(s_version<3)
13605 {
13606 cpylen = (temp_sample.bits==8?1:2)*temp_sample.len;
13607 al_trace("WARNING: Quest SFX %d is in stereo, and may be corrupt.\n",i);
13608 }
13609
13610 6256 memcpy(customsfxdata[i].data,temp_sample.data,cpylen);
13611 6256 }
13612
13613 6256 free(temp_sample.data);
13614 6256 }
13615
13616
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(keepdata)
13617 96 memcpy(customsfxflag, tempflag, WAV_COUNT>>3);
13618
13619 96 sfxdat=0;
13620 96 return 0;
13621 96 }
13622
13623 99 void setupsfx()
13624 {
13625
2/2
✓ Branch 0 taken 25245 times.
✓ Branch 1 taken 99 times.
25344 for(int32_t i=1; i<WAV_COUNT; i++)
13626 {
13627 25245 sprintf(sfx_string[i],"s%03d",i);
13628
13629
2/2
✓ Branch 0 taken 19305 times.
✓ Branch 1 taken 5940 times.
25245 if(i<Z35)
13630 {
13631 5940 strcpy(sfx_string[i], old_sfx_string[i-1]);
13632 5940 }
13633
13634 25245 memset(customsfxflag, 0, WAV_COUNT>>3);
13635
13636 25245 int32_t j=i;
13637
13638
2/2
✓ Branch 0 taken 6039 times.
✓ Branch 1 taken 19206 times.
25245 if(i>Z35)
13639 {
13640 19206 i=Z35;
13641 19206 }
13642
13643 25245 SAMPLE *temp_sample = (SAMPLE *)sfxdata[i].dat;
13644
13645
2/2
✓ Branch 0 taken 7395 times.
✓ Branch 1 taken 17850 times.
25245 if(customsfxdata[j].data!=NULL)
13646 {
13647 // delete [] customsfxdata[j].data;
13648 17850 free(customsfxdata[j].data);
13649 17850 }
13650
13651 // customsfxdata[j].data = new byte[(temp_sample->bits==8?1:2)*temp_sample->len];
13652 25245 customsfxdata[j].data = calloc((temp_sample->bits==8?1:2)*(temp_sample->stereo == 0 ? 1 : 2)*temp_sample->len,1);
13653 25245 customsfxdata[j].bits = temp_sample->bits;
13654 25245 customsfxdata[j].stereo = temp_sample->stereo;
13655 25245 customsfxdata[j].freq = temp_sample->freq;
13656 25245 customsfxdata[j].priority = temp_sample->priority;
13657 25245 customsfxdata[j].len = temp_sample->len;
13658 25245 customsfxdata[j].loop_start = temp_sample->loop_start;
13659 25245 customsfxdata[j].loop_end = temp_sample->loop_end;
13660 25245 customsfxdata[j].param = temp_sample->param;
13661 25245 memcpy(customsfxdata[j].data, (temp_sample->data), (temp_sample->bits==8?1:2)*(temp_sample->stereo==0 ? 1 : 2)*temp_sample->len);
13662 25245 i=j;
13663 25245 }
13664 99 }
13665
13666 extern char *guy_string[eMAXGUYS];
13667 extern const char *old_guy_string[OLDMAXGUYS];
13668
13669 99 int32_t readguys(PACKFILE *f, zquestheader *Header, bool keepdata)
13670 {
13671 dword dummy;
13672 word guy_cversion;
13673 99 word guyversion=0;
13674
13675
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(Header->zelda_version >= 0x193)
13676 {
13677 //section version info
13678
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&guyversion,f,true))
13679 {
13680 return qe_invalid;
13681 }
13682
13683 99 FFCore.quest_format[vGuys] = guyversion;
13684
13685 //al_trace("Guys version %d\n", guyversion);
13686
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&guy_cversion,f,true))
13687 {
13688 return qe_invalid;
13689 }
13690 99 al_trace("Guy CVersion is: %d\n", guy_cversion);
13691 //section size
13692
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetl(&dummy,f,true))
13693 {
13694 return qe_invalid;
13695 }
13696 99 }
13697
13698
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(guyversion > 3)
13699 {
13700
2/2
✓ Branch 0 taken 49152 times.
✓ Branch 1 taken 96 times.
49248 for(int32_t i=0; i<MAXGUYS; i++)
13701 {
13702 char tempname[64];
13703
13704 // rev. 1511 : guyversion = 23. upped to 512 editable enemies. -Gleeok
13705 // if guyversion < 23 then there is only 256 enemies in the packfile, so default the rest.
13706
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 49152 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
49152 if(guyversion < 23 && i >= OLDBETAMAXGUYS && keepdata)
13707 {
13708 memset(tempname, 0, sizeof(char)*64);
13709 sprintf(tempname, "e%03d", i);
13710 strcpy(guy_string[i], tempname);
13711
13712 continue;
13713 }
13714
13715
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!pfread(tempname, 64, f, keepdata))
13716 {
13717 return qe_invalid;
13718 }
13719
13720 // Don't retain names of uneditable enemy entries!
13721
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49152 times.
49152 if(keepdata)
13722 {
13723 // for version upgrade to 2.5
13724
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 49152 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
49152 if(guyversion < 23 && i >= 177)
13725 {
13726 // some of the older builds have names such as 'zz123',
13727 // (this order gets messed up with some eXXX and some zzXXX)
13728 // so let's update to the newer naming convection. -Gleeok
13729 char tmpbuf[64];
13730 memset(tmpbuf, 0, sizeof(char)*64);
13731 sprintf(tmpbuf, "zz%03d", i);
13732
13733 if(memcmp(tempname, tmpbuf, size_t(5)) == 0)
13734 {
13735 memset(tempname, 0, sizeof(char)*64);
13736 sprintf(tempname, "e%03d", i);
13737 }
13738 }
13739
13740
6/6
✓ Branch 0 taken 16992 times.
✓ Branch 1 taken 32160 times.
✓ Branch 2 taken 16128 times.
✓ Branch 3 taken 864 times.
✓ Branch 4 taken 13280 times.
✓ Branch 5 taken 2848 times.
49152 if(i >= OLDMAXGUYS || strlen(tempname)<1 || tempname[strlen(tempname)-1]!=' ')
13741 {
13742 46304 strcpy(guy_string[i], tempname);
13743 46304 }
13744 else
13745 {
13746 2848 strcpy(guy_string[i],old_guy_string[i]);
13747 }
13748 49152 }
13749 49152 }
13750 96 }
13751 else
13752 {
13753
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(keepdata)
13754 {
13755
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 3 times.
1539 for(int32_t i=0; i<eMAXGUYS; i++)
13756 {
13757 1536 sprintf(guy_string[i],"zz%03d",i);
13758 1536 }
13759
13760
2/2
✓ Branch 0 taken 531 times.
✓ Branch 1 taken 3 times.
534 for(int32_t i=0; i<OLDMAXGUYS; i++)
13761 {
13762 531 strcpy(guy_string[i],old_guy_string[i]);
13763 531 }
13764 3 }
13765 }
13766
13767
13768 //finally... section data
13769
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata)
13770 {
13771 99 init_guys(guyversion); //using default data for now...
13772
13773 // Goriya guy fix
13774
3/6
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 96 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<7)))
13775 {
13776
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(get_bit(quest_rules,qr_NEWENEMYTILES))
13777 {
13778 3 guysbuf[gGORIYA].tile=130;
13779 3 guysbuf[gGORIYA].e_tile=130;
13780 3 }
13781 3 }
13782 99 }
13783
13784
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(Header->zelda_version < 0x193)
13785 {
13786 if(get_bit(deprecated_rules,46))
13787 {
13788 guysbuf[eDODONGO].cset=14;
13789 guysbuf[eDODONGO].bosspal=spDIG;
13790 }
13791 }
13792 // Not sure when this first changed, but it's necessary for 2.10, at least
13793 // @TODO: @BUG:1.92 - 1.84? Figure this out exactly for the final 2.50 release.
13794 //2.10 Fixes
13795
3/6
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 96 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<18)))
13796 {
13797 3 guysbuf[eWWIZ].editorflags |= ENEMY_FLAG5;
13798 3 guysbuf[eMOLDORM].editorflags |= ENEMY_FLAG6;
13799 3 guysbuf[eMANHAN].editorflags |= ENEMY_FLAG6;
13800 3 guysbuf[eCENT1].misc3 = 1;
13801 3 guysbuf[eCENT2].misc3 = 1;
13802 3 }
13803
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if((Header->zelda_version <= 0x255) || (Header->zelda_version == 0x255 && Header->build < 47) )
13804 {
13805 99 guysbuf[eWPOLSV].defense[edefWhistle] = ed1HKO;
13806 99 }
13807
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(Header->zelda_version <= 0x210)
13808 {
13809 3 guysbuf[eGLEEOK1F].misc6 = 16;
13810 3 guysbuf[eGLEEOK2F].misc6 = 16;
13811 3 guysbuf[eGLEEOK3F].misc6 = 16;
13812 3 guysbuf[eGLEEOK4F].misc6 = 16;
13813
13814 3 guysbuf[eWIZ1].misc4 = 1; //only set the enemy that needs backward compat, not all of them.
13815 3 guysbuf[eBATROBE].misc4 = 1;
13816 //guysbuf[eSUMMONER].misc4 = 1;
13817 3 guysbuf[eWWIZ].misc4 = 1;
13818 3 guysbuf[eDODONGO].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13819 3 guysbuf[eDODONGOBS].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13820 3 }
13821
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(Header->zelda_version == 0x190)
13822 {
13823 al_trace("Setting Tribble Properties for Version: %x", Header->zelda_version);
13824 guysbuf[eKEESETRIB].misc3 = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13825 guysbuf[eGELTRIB].misc3 = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13826 }
13827
13828 // The versions here may not be correct
13829 // zelda_version>=0x211 handled at guyversion<24
13830
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(Header->zelda_version <= 0x190)
13831 {
13832 guysbuf[eCENT1].misc3 = 0;
13833 guysbuf[eCENT2].misc3 = 0;
13834 guysbuf[eMOLDORM].misc2 = 0;
13835 //guysbuf[eKEESETRIB].misc3 = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13836 //guysbuf[eGELTRIB].misc3 = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13837 }
13838
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 else if(Header->zelda_version <= 0x210)
13839 {
13840 3 guysbuf[eCENT1].misc3 = 1;
13841 3 guysbuf[eCENT2].misc3 = 1;
13842 3 guysbuf[eMOLDORM].misc2 = 0;
13843 3 }
13844
13845
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if ( Header->zelda_version < 0x211 ) //Default rest rates for phantom ghinis, peahats and keese in < 2.50 quests
13846 {
13847 3 guysbuf[eKEESE1].misc16 = 120;
13848 3 guysbuf[eKEESE2].misc16 = 120;
13849 3 guysbuf[eKEESE3].misc16 = 120;
13850 3 guysbuf[eKEESETRIB].misc16 = 120;
13851 3 guysbuf[eKEESE1].misc17 = 16;
13852 3 guysbuf[eKEESE2].misc17 = 16;
13853 3 guysbuf[eKEESE3].misc17 = 16;
13854 3 guysbuf[eKEESETRIB].misc17 = 16;
13855
13856 3 guysbuf[ePEAHAT].misc16 = 80;
13857 3 guysbuf[ePEAHAT].misc17 = 16;
13858
13859 3 guysbuf[eGHINI2].misc16 = 120;
13860 3 guysbuf[eGHINI2].misc17 = 10;
13861
13862 3 }
13863
13864
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 96 times.
99 if(guyversion<=2)
13865 {
13866 3 return readherosprites2(f, guyversion==2?0:-1, 0, keepdata);
13867 }
13868
13869
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(guyversion > 3)
13870 {
13871 guydata tempguy;
13872
13873
2/2
✓ Branch 0 taken 49152 times.
✓ Branch 1 taken 96 times.
49248 for(int32_t i=0; i<MAXGUYS; i++)
13874 {
13875
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 49152 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
49152 if(guyversion < 23 && keepdata) // May 2012 : 512 max enemies
13876 {
13877 if(i >= OLDBETAMAXGUYS)
13878 {
13879 memset(&guysbuf[i], 0, sizeof(guydata));
13880 continue;
13881 }
13882 }
13883
13884 49152 memset(&tempguy, 0, sizeof(guydata));
13885
13886
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetl(&(tempguy.flags),f,keepdata))
13887 {
13888 return qe_invalid;
13889 }
13890
13891
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetl(&(tempguy.flags2),f,keepdata))
13892 {
13893 return qe_invalid;
13894 }
13895
13896
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 37888 times.
49152 if ( guyversion >= 36 ) //expanded tiles
13897 {
13898
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.tile),f,keepdata))
13899 {
13900 return qe_invalid;
13901 }
13902 11264 }
13903 else
13904 {
13905
1/2
✓ Branch 0 taken 37888 times.
✗ Branch 1 not taken.
37888 if(!p_igetw(&(tempguy.tile),f,keepdata))
13906 {
13907 return qe_invalid;
13908 }
13909 }
13910
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_getc(&(tempguy.width),f,keepdata))
13911 {
13912 return qe_invalid;
13913 }
13914
13915
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_getc(&(tempguy.height),f,keepdata))
13916 {
13917 return qe_invalid;
13918 }
13919
13920
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 37888 times.
49152 if ( guyversion >= 36 ) //expanded tiles
13921 {
13922
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.s_tile),f,keepdata))
13923 {
13924 return qe_invalid;
13925 }
13926 11264 }
13927 else
13928 {
13929
1/2
✓ Branch 0 taken 37888 times.
✗ Branch 1 not taken.
37888 if(!p_igetw(&(tempguy.s_tile),f,keepdata))
13930 {
13931 return qe_invalid;
13932 }
13933 }
13934
13935
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_getc(&(tempguy.s_width),f,keepdata))
13936 {
13937 return qe_invalid;
13938 }
13939
13940
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_getc(&(tempguy.s_height),f,keepdata))
13941 {
13942 return qe_invalid;
13943 }
13944
13945
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 37888 times.
49152 if ( guyversion >= 36 ) //expanded tiles
13946 {
13947
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.e_tile),f,keepdata))
13948 {
13949 return qe_invalid;
13950 }
13951 11264 }
13952 else
13953 {
13954
1/2
✓ Branch 0 taken 37888 times.
✗ Branch 1 not taken.
37888 if(!p_igetw(&(tempguy.e_tile),f,keepdata))
13955 {
13956 return qe_invalid;
13957 }
13958 }
13959
13960
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_getc(&(tempguy.e_width),f,keepdata))
13961 {
13962 return qe_invalid;
13963 }
13964
13965
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_getc(&(tempguy.e_height),f,keepdata))
13966 {
13967 return qe_invalid;
13968 }
13969
13970
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&(tempguy.hp),f,keepdata))
13971 {
13972 return qe_invalid;
13973 }
13974
13975
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&(tempguy.family),f,keepdata))
13976 {
13977 return qe_invalid;
13978 }
13979
13980
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 49152 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
49152 if(guyversion < 9 && (i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)) // Whoops, forgot about Darknuts...
13981 {
13982 if(get_bit(quest_rules,qr_NEWENEMYTILES))
13983 {
13984 tempguy.s_tile=tempguy.e_tile+120;
13985 tempguy.s_width=tempguy.e_width;
13986 tempguy.s_height=tempguy.e_height;
13987 }
13988 else tempguy.s_tile=860;
13989 }
13990
13991
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&(tempguy.cset),f,keepdata))
13992 {
13993 return qe_invalid;
13994 }
13995
13996
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&(tempguy.anim),f,keepdata))
13997 {
13998 return qe_invalid;
13999 }
14000
14001
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&(tempguy.e_anim),f,keepdata))
14002 {
14003 return qe_invalid;
14004 }
14005
14006
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&(tempguy.frate),f,keepdata))
14007 {
14008 return qe_invalid;
14009 }
14010
14011
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&(tempguy.e_frate),f,keepdata))
14012 {
14013 return qe_invalid;
14014 }
14015
14016
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(guyversion < 13) // April 2009
14017 {
14018 if(get_bit(deprecated_rules, qr_SLOWENEMYANIM_DEP))
14019 {
14020 tempguy.frate *= 2;
14021 tempguy.e_frate *= 2;
14022 }
14023 }
14024
14025
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(guyversion < 14) // May 1 2009
14026 {
14027 if(tempguy.anim==a2FRMSLOW)
14028 {
14029 tempguy.anim=a2FRM;
14030 tempguy.frate *= 2;
14031 }
14032
14033 if(tempguy.e_anim==a2FRMSLOW)
14034 {
14035 tempguy.e_anim=a2FRM;
14036 tempguy.e_frate *= 2;
14037 }
14038
14039 if(tempguy.anim==aFLIPSLOW)
14040 {
14041 tempguy.anim=aFLIP;
14042 tempguy.frate *= 2;
14043 }
14044
14045 if(tempguy.e_anim==aFLIPSLOW)
14046 {
14047 tempguy.e_anim=aFLIP;
14048 tempguy.e_frate *= 2;
14049 }
14050
14051 if(tempguy.anim == aNEWDWALK) tempguy.anim = a4FRM4DIR;
14052
14053 if(tempguy.e_anim == aNEWDWALK) tempguy.e_anim = a4FRM4DIR;
14054
14055 if(tempguy.anim == aNEWPOLV || tempguy.anim == a4FRM3TRAP)
14056 {
14057 tempguy.anim=a4FRM4DIR;
14058 tempguy.s_tile=(get_bit(quest_rules,qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
14059 }
14060
14061 if(tempguy.e_anim == aNEWPOLV || tempguy.e_anim == a4FRM3TRAP)
14062 {
14063 tempguy.e_anim=a4FRM4DIR;
14064 tempguy.s_tile=(get_bit(quest_rules,qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
14065 }
14066 }
14067
14068
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&(tempguy.dp),f,keepdata))
14069 {
14070 return qe_invalid;
14071 }
14072
14073 //correction for guy fire
14074
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(guyversion < 6)
14075 {
14076 if(i == gFIRE)
14077 tempguy.dp = 2;
14078 }
14079
14080
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&(tempguy.wdp),f,keepdata))
14081 {
14082 return qe_invalid;
14083 }
14084
14085
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&(tempguy.weapon),f,keepdata))
14086 {
14087 return qe_invalid;
14088 }
14089
14090 //correction for bosses using triple, "rising" fireballs
14091
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(guyversion < 5)
14092 {
14093 if(i == eLAQUAM || i == eRAQUAM || i == eGOHMA1 || i == eGOHMA2 ||
14094 i == eGOHMA3 || i == eGOHMA4)
14095 {
14096 if(tempguy.weapon == ewFireball)
14097 tempguy.weapon = ewFireball2;
14098 }
14099 }
14100
14101
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&(tempguy.rate),f,keepdata))
14102 {
14103 return qe_invalid;
14104 }
14105
14106
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&(tempguy.hrate),f,keepdata))
14107 {
14108 return qe_invalid;
14109 }
14110
14111
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&(tempguy.step),f,keepdata))
14112 {
14113 return qe_invalid;
14114 }
14115
14116 // HIGHLY UNORTHODOX UPDATING THING, part 2
14117
3/4
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 48640 times.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
49152 if(fixpolsvoice && tempguy.family==eePOLSV)
14118 {
14119 tempguy.step /= 2;
14120 }
14121
14122
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&(tempguy.homing),f,keepdata))
14123 {
14124 return qe_invalid;
14125 }
14126
14127
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&(tempguy.grumble),f,keepdata))
14128 {
14129 return qe_invalid;
14130 }
14131
14132
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&(tempguy.item_set),f,keepdata))
14133 {
14134 return qe_invalid;
14135 }
14136
14137
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(guyversion>=22) // Version 22: Expand misc attributes to 32 bits
14138 {
14139
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetl(&(tempguy.misc1),f,keepdata))
14140 {
14141 return qe_invalid;
14142 }
14143
14144
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetl(&(tempguy.misc2),f,keepdata))
14145 {
14146 return qe_invalid;
14147 }
14148
14149
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetl(&(tempguy.misc3),f,keepdata))
14150 {
14151 return qe_invalid;
14152 }
14153
14154
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetl(&(tempguy.misc4),f,keepdata))
14155 {
14156 return qe_invalid;
14157 }
14158
14159
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetl(&(tempguy.misc5),f,keepdata))
14160 {
14161 return qe_invalid;
14162 }
14163
14164
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetl(&(tempguy.misc6),f,keepdata))
14165 {
14166 return qe_invalid;
14167 }
14168
14169
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetl(&(tempguy.misc7),f,keepdata))
14170 {
14171 return qe_invalid;
14172 }
14173
14174
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetl(&(tempguy.misc8),f,keepdata))
14175 {
14176 return qe_invalid;
14177 }
14178
14179
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetl(&(tempguy.misc9),f,keepdata))
14180 {
14181 return qe_invalid;
14182 }
14183
14184
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetl(&(tempguy.misc10),f,keepdata))
14185 {
14186 return qe_invalid;
14187 }
14188 49152 }
14189 else
14190 {
14191 int16_t tempMisc;
14192
14193 if(!p_igetw(&tempMisc,f,keepdata))
14194 {
14195 return qe_invalid;
14196 }
14197
14198 tempguy.misc1=tempMisc;
14199
14200 if(!p_igetw(&tempMisc,f,keepdata))
14201 {
14202 return qe_invalid;
14203 }
14204
14205 tempguy.misc2=tempMisc;
14206
14207 if(!p_igetw(&tempMisc,f,keepdata))
14208 {
14209 return qe_invalid;
14210 }
14211
14212 tempguy.misc3=tempMisc;
14213
14214 if(!p_igetw(&tempMisc,f,keepdata))
14215 {
14216 return qe_invalid;
14217 }
14218
14219 tempguy.misc4=tempMisc;
14220
14221 if(!p_igetw(&tempMisc,f,keepdata))
14222 {
14223 return qe_invalid;
14224 }
14225
14226 tempguy.misc5=tempMisc;
14227
14228 if(guyversion < 13) // April 2009 - a tiny Wizzrobe update
14229 {
14230 if(tempguy.family == eeWIZZ && !(tempguy.misc1))
14231 tempguy.misc5 = 74;
14232 }
14233
14234 if(!p_igetw(&tempMisc,f,keepdata))
14235 {
14236 return qe_invalid;
14237 }
14238
14239 tempguy.misc6=tempMisc;
14240
14241 if(!p_igetw(&tempMisc,f,keepdata))
14242 {
14243 return qe_invalid;
14244 }
14245
14246 tempguy.misc7=tempMisc;
14247
14248 if(!p_igetw(&tempMisc,f,keepdata))
14249 {
14250 return qe_invalid;
14251 }
14252
14253 tempguy.misc8=tempMisc;
14254
14255 if(!p_igetw(&tempMisc,f,keepdata))
14256 {
14257 return qe_invalid;
14258 }
14259
14260 tempguy.misc9=tempMisc;
14261
14262 if(!p_igetw(&tempMisc,f,keepdata))
14263 {
14264 return qe_invalid;
14265 }
14266
14267 tempguy.misc10=tempMisc;
14268 }
14269
14270
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&(tempguy.bgsfx),f,keepdata))
14271 {
14272 return qe_invalid;
14273 }
14274
14275
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&(tempguy.bosspal),f,keepdata))
14276 {
14277 return qe_invalid;
14278 }
14279
14280
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&(tempguy.extend),f,keepdata))
14281 {
14282 return qe_invalid;
14283 }
14284
14285 //! Enemy Defences
14286
14287 //If a 2.50 quest, use only the 2.5 defences.
14288
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49152 times.
49152 if(guyversion >= 16 ) // November 2009 - Super Enemy Editor
14289 {
14290
2/2
✓ Branch 0 taken 933888 times.
✓ Branch 1 taken 49152 times.
983040 for(int32_t j=0; j<edefLAST; j++)
14291 {
14292
1/2
✓ Branch 0 taken 933888 times.
✗ Branch 1 not taken.
933888 if(!p_getc(&(tempguy.defense[j]),f,keepdata))
14293 {
14294 return qe_invalid;
14295 }
14296 933888 }
14297 //then copy the generic script defence to all the new script defences
14298
14299 49152 }
14300
14301
14302
14303
14304
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49152 times.
49152 if(guyversion >= 18)
14305 {
14306
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_getc(&(tempguy.hitsfx),f,keepdata))
14307 {
14308 return qe_invalid;
14309 }
14310
14311
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_getc(&(tempguy.deadsfx),f,keepdata))
14312 {
14313 return qe_invalid;
14314 }
14315 49152 }
14316
14317
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(guyversion >= 22)
14318 {
14319
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetl(&(tempguy.misc11),f,keepdata))
14320 {
14321 return qe_invalid;
14322 }
14323
14324
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetl(&(tempguy.misc12),f,keepdata))
14325 {
14326 return qe_invalid;
14327 }
14328 49152 }
14329 else if(guyversion >= 19)
14330 {
14331 int16_t tempMisc;
14332
14333 if(!p_igetw(&tempMisc,f,keepdata))
14334 {
14335 return qe_invalid;
14336 }
14337
14338 tempguy.misc11=tempMisc;
14339
14340 if(!p_igetw(&tempMisc,f,keepdata))
14341 {
14342 return qe_invalid;
14343 }
14344
14345 tempguy.misc12=tempMisc;
14346 }
14347
14348 //If a 2.54 or later quest, use all of the defences.
14349
2/2
✓ Branch 0 taken 37888 times.
✓ Branch 1 taken 11264 times.
49152 if(guyversion > 24) // Add new guyversion conditional statement
14350 {
14351
2/2
✓ Branch 0 taken 247808 times.
✓ Branch 1 taken 11264 times.
259072 for(int32_t j=edefLAST; j<edefLAST255; j++)
14352 {
14353
1/2
✓ Branch 0 taken 247808 times.
✗ Branch 1 not taken.
247808 if(!p_getc(&(tempguy.defense[j]),f,keepdata))
14354 {
14355 return qe_invalid;
14356 }
14357 247808 }
14358 11264 }
14359
14360
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 37888 times.
49152 if(guyversion <= 24) // Port over generic script settings from old quests in the new editor.
14361 {
14362
2/2
✓ Branch 0 taken 378880 times.
✓ Branch 1 taken 37888 times.
416768 for(int32_t j=edefSCRIPT01; j<=edefSCRIPT10; j++)
14363 {
14364 378880 tempguy.defense[j] = tempguy.defense[edefSCRIPT] ;
14365 378880 }
14366 37888 }
14367
14368 //tilewidth, tileheight, hitwidth, hitheight, hitzheight, hitxofs, hityofs, hitzofs
14369
2/2
✓ Branch 0 taken 37888 times.
✓ Branch 1 taken 11264 times.
49152 if(guyversion > 25)
14370 {
14371
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.txsz),f,keepdata))
14372 {
14373 return qe_invalid;
14374 }
14375
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.tysz),f,keepdata))
14376 {
14377 return qe_invalid;
14378 }
14379
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.hxsz),f,keepdata))
14380 {
14381 return qe_invalid;
14382 }
14383
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.hysz),f,keepdata))
14384 {
14385 return qe_invalid;
14386 }
14387
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.hzsz),f,keepdata))
14388 {
14389 return qe_invalid;
14390 }
14391 /* Is it safe to read a fixed with getl, or do I need to typecast it? -Z
14392
14393 */
14394 11264 }
14395 //More Enemy Editor vars for 2.60
14396
2/2
✓ Branch 0 taken 37888 times.
✓ Branch 1 taken 11264 times.
49152 if(guyversion > 26)
14397 {
14398
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.hxofs),f,keepdata))
14399 {
14400 return qe_invalid;
14401 }
14402
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.hyofs),f,keepdata))
14403 {
14404 return qe_invalid;
14405 }
14406
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.xofs),f,keepdata))
14407 {
14408 return qe_invalid;
14409 }
14410
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.yofs),f,keepdata))
14411 {
14412 return qe_invalid;
14413 }
14414
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.zofs),f,keepdata))
14415 {
14416 return qe_invalid;
14417 }
14418 11264 }
14419
14420
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 37888 times.
49152 if(guyversion <= 27) // Port over generic script settings from old quests in the new editor.
14421 {
14422 37888 tempguy.wpnsprite = 0;
14423 37888 }
14424
14425
2/2
✓ Branch 0 taken 37888 times.
✓ Branch 1 taken 11264 times.
49152 if(guyversion > 27)
14426 {
14427
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.wpnsprite),f,keepdata))
14428 {
14429 return qe_invalid;
14430 }
14431 11264 }
14432
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 37888 times.
49152 if(guyversion <= 28) // Port over generic script settings from old quests in the new editor.
14433 {
14434 37888 tempguy.SIZEflags = 0;
14435 37888 }
14436
2/2
✓ Branch 0 taken 37888 times.
✓ Branch 1 taken 11264 times.
49152 if(guyversion > 28)
14437 {
14438
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.SIZEflags),f,keepdata))
14439 {
14440 return qe_invalid;
14441 }
14442
14443 11264 }
14444
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 37888 times.
49152 if(guyversion < 30) // Port over generic script settings from old quests in the new editor.
14445 {
14446 37888 tempguy.frozentile = 0;
14447 37888 tempguy.frozencset = 0;
14448 37888 tempguy.frozenclock = 0;
14449
2/2
✓ Branch 0 taken 378880 times.
✓ Branch 1 taken 37888 times.
416768 for ( int32_t q = 0; q < 10; q++ ) tempguy.frozenmisc[q] = 0;
14450 37888 }
14451
2/2
✓ Branch 0 taken 37888 times.
✓ Branch 1 taken 11264 times.
49152 if(guyversion >= 30)
14452 {
14453
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.frozentile),f,keepdata))
14454 {
14455 return qe_invalid;
14456 }
14457
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.frozencset),f,keepdata))
14458 {
14459 return qe_invalid;
14460 }
14461
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.frozenclock),f,keepdata))
14462 {
14463 return qe_invalid;
14464 }
14465
2/2
✓ Branch 0 taken 112640 times.
✓ Branch 1 taken 11264 times.
123904 for ( int32_t q = 0; q < 10; q++ ) {
14466
1/2
✓ Branch 0 taken 112640 times.
✗ Branch 1 not taken.
112640 if(!p_igetw(&(tempguy.frozenmisc[q]),f,keepdata))
14467 {
14468 return qe_invalid;
14469 }
14470 112640 }
14471
14472 11264 }
14473
14474
2/2
✓ Branch 0 taken 37888 times.
✓ Branch 1 taken 11264 times.
49152 if(guyversion >= 34)
14475 {
14476
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetw(&(tempguy.firesfx),f,keepdata))
14477 {
14478 return qe_invalid;
14479 }
14480
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.misc16),f,keepdata))
14481 {
14482 return qe_invalid;
14483 }
14484
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.misc17),f,keepdata))
14485 {
14486 return qe_invalid;
14487 }
14488
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.misc18),f,keepdata))
14489 {
14490 return qe_invalid;
14491 }
14492
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.misc19),f,keepdata))
14493 {
14494 return qe_invalid;
14495 }
14496
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.misc20),f,keepdata))
14497 {
14498 return qe_invalid;
14499 }
14500
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.misc21),f,keepdata))
14501 {
14502 return qe_invalid;
14503 }
14504
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.misc22),f,keepdata))
14505 {
14506 return qe_invalid;
14507 }
14508
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.misc23),f,keepdata))
14509 {
14510 return qe_invalid;
14511 }
14512
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.misc24),f,keepdata))
14513 {
14514 return qe_invalid;
14515 }
14516
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.misc25),f,keepdata))
14517 {
14518 return qe_invalid;
14519 }
14520
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.misc26),f,keepdata))
14521 {
14522 return qe_invalid;
14523 }
14524
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.misc27),f,keepdata))
14525 {
14526 return qe_invalid;
14527 }
14528
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.misc28),f,keepdata))
14529 {
14530 return qe_invalid;
14531 }
14532
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.misc29),f,keepdata))
14533 {
14534 return qe_invalid;
14535 }
14536
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.misc30),f,keepdata))
14537 {
14538 return qe_invalid;
14539 }
14540
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.misc31),f,keepdata))
14541 {
14542 return qe_invalid;
14543 }
14544
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.misc32),f,keepdata))
14545 {
14546 return qe_invalid;
14547 }
14548
14549
2/2
✓ Branch 0 taken 360448 times.
✓ Branch 1 taken 11264 times.
371712 for ( int32_t q = 0; q < 32; q++ ) {
14550
1/2
✓ Branch 0 taken 360448 times.
✗ Branch 1 not taken.
360448 if(!p_igetl(&(tempguy.movement[q]),f,keepdata))
14551 {
14552 return qe_invalid;
14553 }
14554 360448 }
14555
2/2
✓ Branch 0 taken 360448 times.
✓ Branch 1 taken 11264 times.
371712 for ( int32_t q = 0; q < 32; q++ ) {
14556
1/2
✓ Branch 0 taken 360448 times.
✗ Branch 1 not taken.
360448 if(!p_igetl(&(tempguy.new_weapon[q]),f,keepdata))
14557 {
14558 return qe_invalid;
14559 }
14560 360448 }
14561
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetw(&(tempguy.script),f,keepdata))
14562 {
14563 return qe_invalid;
14564 }
14565 //al_trace("NPC Script ID is: %d\n",tempguy.script);
14566
2/2
✓ Branch 0 taken 90112 times.
✓ Branch 1 taken 11264 times.
101376 for ( int32_t q = 0; q < 8; q++ )
14567 {
14568
1/2
✓ Branch 0 taken 90112 times.
✗ Branch 1 not taken.
90112 if(!p_igetl(&(tempguy.initD[q]),f,keepdata))
14569 {
14570 return qe_invalid;
14571 }
14572 90112 }
14573
2/2
✓ Branch 0 taken 22528 times.
✓ Branch 1 taken 11264 times.
33792 for ( int32_t q = 0; q < 2; q++ )
14574 {
14575
1/2
✓ Branch 0 taken 22528 times.
✗ Branch 1 not taken.
22528 if(!p_igetl(&(tempguy.initA[q]),f,keepdata))
14576 {
14577 return qe_invalid;
14578 }
14579 22528 }
14580
14581 11264 }
14582
14583
2/2
✓ Branch 0 taken 37888 times.
✓ Branch 1 taken 11264 times.
49152 if(guyversion >= 37)
14584 {
14585
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.editorflags),f,keepdata))
14586 {
14587 return qe_invalid;
14588 }
14589 11264 }
14590
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 37888 times.
49152 if ( guyversion < 37 ) { tempguy.editorflags = 0; }
14591
2/2
✓ Branch 0 taken 37888 times.
✓ Branch 1 taken 11264 times.
49152 if(guyversion >= 38)
14592 {
14593
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.misc13),f,keepdata))
14594 {
14595 return qe_invalid;
14596 }
14597
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.misc14),f,keepdata))
14598 {
14599 return qe_invalid;
14600 }
14601
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.misc15),f,keepdata))
14602 {
14603 return qe_invalid;
14604 }
14605
14606 11264 }
14607
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 37888 times.
49152 if ( guyversion < 38 )
14608 {
14609 37888 tempguy.misc13 = 0;
14610 37888 tempguy.misc14 = 0;
14611 37888 tempguy.misc15 = 0;
14612 37888 }
14613
14614
2/2
✓ Branch 0 taken 37888 times.
✓ Branch 1 taken 11264 times.
49152 if ( guyversion >= 39 )
14615 {
14616
2/2
✓ Branch 0 taken 90112 times.
✓ Branch 1 taken 11264 times.
101376 for ( int32_t q = 0; q < 8; q++ )
14617 {
14618
2/2
✓ Branch 0 taken 5857280 times.
✓ Branch 1 taken 90112 times.
5947392 for ( int32_t w = 0; w < 65; w++ )
14619 {
14620
1/2
✓ Branch 0 taken 5857280 times.
✗ Branch 1 not taken.
5857280 if(!p_getc(&(tempguy.initD_label[q][w]),f,keepdata))
14621 {
14622 return qe_invalid;
14623 }
14624 5857280 }
14625
2/2
✓ Branch 0 taken 5857280 times.
✓ Branch 1 taken 90112 times.
5947392 for ( int32_t w = 0; w < 65; w++ )
14626 {
14627
1/2
✓ Branch 0 taken 5857280 times.
✗ Branch 1 not taken.
5857280 if(!p_getc(&(tempguy.weapon_initD_label[q][w]),f,keepdata))
14628 {
14629 return qe_invalid;
14630 }
14631 5857280 }
14632 90112 }
14633
14634
14635 11264 }
14636
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 37888 times.
49152 if ( guyversion < 39 ) //apply old InitD strings to both
14637 {
14638
2/2
✓ Branch 0 taken 303104 times.
✓ Branch 1 taken 37888 times.
340992 for ( int32_t q = 0; q < 8; q++ )
14639 {
14640 303104 sprintf(tempguy.initD_label[q],"InitD[%d]",q);
14641 303104 sprintf(tempguy.weapon_initD_label[q],"InitD[%d]",q);
14642 303104 }
14643 37888 }
14644
2/2
✓ Branch 0 taken 37888 times.
✓ Branch 1 taken 11264 times.
49152 if ( guyversion >= 40 )
14645 {
14646
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetw(&(tempguy.weaponscript),f,keepdata))
14647 {
14648 return qe_invalid;
14649 }
14650 11264 }
14651
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 37888 times.
49152 if ( guyversion < 40 )
14652 {
14653 37888 tempguy.weaponscript = 0;
14654 37888 }
14655 //eweapon script InitD
14656
2/2
✓ Branch 0 taken 37888 times.
✓ Branch 1 taken 11264 times.
49152 if ( guyversion >= 41 )
14657 {
14658
2/2
✓ Branch 0 taken 90112 times.
✓ Branch 1 taken 11264 times.
101376 for ( int32_t q = 0; q < 8; q++ )
14659 {
14660
1/2
✓ Branch 0 taken 90112 times.
✗ Branch 1 not taken.
90112 if(!p_igetl(&(tempguy.weap_initiald[q]),f,keepdata))
14661 {
14662 return qe_invalid;
14663 }
14664 90112 }
14665
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if ( guy_cversion < 4 )
14666 {
14667 if ( tempguy.family == eeKEESE )
14668 {
14669
14670 if ( !tempguy.misc1 )
14671 {
14672 tempguy.misc16 = 120;
14673 tempguy.misc17 = 16;
14674
14675 }
14676 }
14677 if ( tempguy.family == eePEAHAT )
14678 {
14679 tempguy.misc16 = 80;
14680 tempguy.misc17 = 16;
14681 }
14682
14683 if ( tempguy.family == eeGHINI )
14684 {
14685 tempguy.misc16 = 120;
14686 tempguy.misc17 = 10;
14687 }
14688
14689 }
14690 11264 }
14691
14692
14693
14694 //default weapon sprites (quest version < 2.54)
14695 //port over old defaults -Z
14696
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 37888 times.
49152 if(guyversion < 32)
14697 {
14698
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37888 times.
37888 if ( tempguy.wpnsprite <= 0 )
14699 {
14700
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 1257 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 31522 times.
✓ Branch 4 taken 289 times.
✓ Branch 5 taken 306 times.
✓ Branch 6 taken 908 times.
✓ Branch 7 taken 472 times.
✓ Branch 8 taken 873 times.
✓ Branch 9 taken 77 times.
✓ Branch 10 taken 18 times.
✓ Branch 11 taken 130 times.
✓ Branch 12 taken 18 times.
✓ Branch 13 taken 355 times.
✓ Branch 14 taken 734 times.
✓ Branch 15 taken 104 times.
✓ Branch 16 taken 74 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 751 times.
37888 switch(tempguy.weapon)
14701 {
14702 case wNone:
14703 31522 tempguy.wpnsprite = 0; break;
14704
14705 case wSword:
14706 case wBeam:
14707 case wBrang:
14708 case wBomb:
14709 case wSBomb:
14710 case wLitBomb:
14711 case wLitSBomb:
14712 case wArrow:
14713 case wFire:
14714 case wWhistle:
14715 case wBait:
14716 case wWand:
14717 case wMagic:
14718 case wCatching:
14719 case wWind:
14720 case wRefMagic:
14721 case wRefFireball:
14722 case wRefRock:
14723 case wHammer:
14724 case wHookshot:
14725 case wHSHandle:
14726 case wHSChain:
14727 case wSSparkle:
14728 case wFSparkle:
14729 case wSmack:
14730 case wPhantom:
14731 case wCByrna:
14732 case wRefBeam:
14733 case wStomp:
14734 case lwMax:
14735 case wScript1:
14736 case wScript2:
14737 case wScript3:
14738 case wScript4:
14739 case wScript5:
14740 case wScript6:
14741 case wScript7:
14742 case wScript8:
14743 case wScript9:
14744 case wScript10:
14745 case wIce:
14746 //Cannot use any of these weapons yet.
14747 tempguy.wpnsprite = -1;
14748 break;
14749
14750 case wEnemyWeapons:
14751 1257 case ewFireball: tempguy.wpnsprite = 17; break;
14752
14753 289 case ewArrow: tempguy.wpnsprite = 19; break;
14754 306 case ewBrang: tempguy.wpnsprite = 4; break;
14755 908 case ewSword: tempguy.wpnsprite = 20; break;
14756 472 case ewRock: tempguy.wpnsprite = 18; break;
14757 873 case ewMagic: tempguy.wpnsprite = 21; break;
14758 77 case ewBomb: tempguy.wpnsprite = 78; break;
14759 18 case ewSBomb: tempguy.wpnsprite = 79; break;
14760 130 case ewLitBomb: tempguy.wpnsprite = 76; break;
14761 18 case ewLitSBomb: tempguy.wpnsprite = 77; break;
14762 355 case ewFireTrail: tempguy.wpnsprite = 80; break;
14763 734 case ewFlame: tempguy.wpnsprite = 35; break;
14764 104 case ewWind: tempguy.wpnsprite = 36; break;
14765 74 case ewFlame2: tempguy.wpnsprite = 81; break;
14766 case ewFlame2Trail: tempguy.wpnsprite = 82; break;
14767 case ewIce: tempguy.wpnsprite = 83; break;
14768 751 case ewFireball2: tempguy.wpnsprite = 17; break; //fireball (rising)
14769
14770
14771 default: break; //No assign.
14772 }
14773 37888 }
14774 37888 }
14775
14776 //default weapon fire sound (quest version < 2.54)
14777 //port over old defaults and zero new data. -Z
14778
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 37888 times.
49152 if(guyversion < 34)
14779 {
14780
2/2
✓ Branch 0 taken 1212416 times.
✓ Branch 1 taken 37888 times.
1250304 for ( int32_t q = 0; q < 32; q++ )
14781 {
14782 1212416 tempguy.movement[q] = 0;
14783 1212416 tempguy.new_weapon[q] = 0;
14784
14785 1212416 }
14786
14787 //NPC Script attributes.
14788 37888 tempguy.script = 0; //No scripted enemies existed. -Z
14789
2/2
✓ Branch 0 taken 303104 times.
✓ Branch 1 taken 37888 times.
340992 for ( int32_t q = 0; q < 8; q++ ) tempguy.initD[q] = 0; //Script Data
14790
2/2
✓ Branch 0 taken 75776 times.
✓ Branch 1 taken 37888 times.
113664 for ( int32_t q = 0; q < 2; q++ ) tempguy.initA[q] = 0; //Script Data
14791
14792 37888 tempguy.misc16 = 0;
14793 37888 tempguy.misc17 = 0;
14794 37888 tempguy.misc18 = 0;
14795 37888 tempguy.misc19 = 0;
14796 37888 tempguy.misc20 = 0;
14797 37888 tempguy.misc21 = 0;
14798 37888 tempguy.misc22 = 0;
14799 37888 tempguy.misc23 = 0;
14800 37888 tempguy.misc24 = 0;
14801 37888 tempguy.misc25 = 0;
14802 37888 tempguy.misc26 = 0;
14803 37888 tempguy.misc27 = 0;
14804 37888 tempguy.misc28 = 0;
14805 37888 tempguy.misc29 = 0;
14806 37888 tempguy.misc30 = 0;
14807 37888 tempguy.misc31 = 0;
14808 37888 tempguy.misc32 = 0;
14809
14810 //old default sounds
14811
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37888 times.
37888 if ( tempguy.firesfx <= 0 )
14812 {
14813
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 1257 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 31522 times.
✓ Branch 4 taken 289 times.
✓ Branch 5 taken 306 times.
✓ Branch 6 taken 908 times.
✓ Branch 7 taken 472 times.
✓ Branch 8 taken 873 times.
✓ Branch 9 taken 77 times.
✓ Branch 10 taken 18 times.
✓ Branch 11 taken 130 times.
✓ Branch 12 taken 18 times.
✓ Branch 13 taken 355 times.
✓ Branch 14 taken 734 times.
✓ Branch 15 taken 104 times.
✓ Branch 16 taken 74 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 751 times.
37888 switch(tempguy.weapon)
14814 {
14815 case wNone:
14816 31522 tempguy.firesfx = 0; break;
14817
14818 case wSword:
14819 case wBeam:
14820 case wBrang:
14821 case wBomb:
14822 case wSBomb:
14823 case wLitBomb:
14824 case wLitSBomb:
14825 case wArrow:
14826 case wFire:
14827 case wWhistle:
14828 case wBait:
14829 case wWand:
14830 case wMagic:
14831 case wCatching:
14832 case wWind:
14833 case wRefMagic:
14834 case wRefFireball:
14835 case wRefRock:
14836 case wHammer:
14837 case wHookshot:
14838 case wHSHandle:
14839 case wHSChain:
14840 case wSSparkle:
14841 case wFSparkle:
14842 case wSmack:
14843 case wPhantom:
14844 case wCByrna:
14845 case wRefBeam:
14846 case wStomp:
14847 case lwMax:
14848 case wScript1:
14849 case wScript2:
14850 case wScript3:
14851 case wScript4:
14852 case wScript5:
14853 case wScript6:
14854 case wScript7:
14855 case wScript8:
14856 case wScript9:
14857 case wScript10:
14858 case wIce:
14859 //Cannot use any of these weapons yet.
14860 tempguy.firesfx = -1;
14861 break;
14862
14863 case wEnemyWeapons:
14864 1257 case ewFireball: tempguy.firesfx = 40; break;
14865
14866 289 case ewArrow: tempguy.firesfx = 1; break; //Ghost.zh has 0?
14867 306 case ewBrang: tempguy.firesfx = 4; break; //Ghost.zh has 0?
14868 908 case ewSword: tempguy.firesfx = 20; break; //Ghost.zh has 0?
14869 472 case ewRock: tempguy.firesfx = 51; break;
14870 873 case ewMagic: tempguy.firesfx = 32; break;
14871 77 case ewBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14872 18 case ewSBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14873 130 case ewLitBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14874 18 case ewLitSBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14875 355 case ewFireTrail: tempguy.firesfx = 13; break;
14876 734 case ewFlame: tempguy.firesfx = 13; break;
14877 104 case ewWind: tempguy.firesfx = 32; break;
14878 74 case ewFlame2: tempguy.firesfx = 13; break;
14879 case ewFlame2Trail: tempguy.firesfx = 13; break;
14880 case ewIce: tempguy.firesfx = 44; break;
14881 751 case ewFireball2: tempguy.firesfx = 40; break; //fireball (rising)
14882
14883 //what about special attacks (e.g. summoning == 56)
14884 default: break; //No assign.
14885 }
14886 37888 }
14887 37888 }
14888
14889 //Port hardcoded hit sound to the enemy hitsfx defaults for older quests.
14890
4/6
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 37888 times.
✓ Branch 2 taken 11264 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 11264 times.
49152 if(Header->zelda_version <= 0x250 || ( Header->zelda_version > 0x250 && guyversion < 35 ))
14891 {
14892
2/2
✓ Branch 0 taken 2994 times.
✓ Branch 1 taken 34894 times.
37888 if ( tempguy.hitsfx == 0 ) tempguy.hitsfx = 11;
14893 37888 }
14894 //Keese and bat halt rates.
14895
3/4
✓ Branch 0 taken 37888 times.
✓ Branch 1 taken 11264 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 37888 times.
49152 if ( guyversion < 42 && guy_cversion < 4 )
14896 {
14897
14898
2/2
✓ Branch 0 taken 37378 times.
✓ Branch 1 taken 510 times.
37888 if ( tempguy.family == eeKEESE )
14899 {
14900
14901
2/2
✓ Branch 0 taken 196 times.
✓ Branch 1 taken 314 times.
510 if ( !tempguy.misc1 )
14902 {
14903 314 tempguy.misc16 = 120;
14904 314 tempguy.misc17 = 16;
14905
14906 314 }
14907 510 }
14908
2/2
✓ Branch 0 taken 37726 times.
✓ Branch 1 taken 162 times.
37888 if ( tempguy.family == eePEAHAT )
14909 {
14910 162 tempguy.misc16 = 80;
14911 162 tempguy.misc17 = 16;
14912 162 }
14913
2/2
✓ Branch 0 taken 37814 times.
✓ Branch 1 taken 74 times.
37888 if ( tempguy.family == eeGHINI )
14914 {
14915 74 tempguy.misc16 = 120;
14916 74 tempguy.misc17 = 10;
14917 74 }
14918
14919
14920 37888 }
14921
14922
14923 //miscellaneous other corrections
14924 //fix the mirror wizzrobe -DD
14925
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(guyversion < 7)
14926 {
14927 if(i == eMWIZ)
14928 {
14929 tempguy.misc2 = 0;
14930 tempguy.misc4 = 1;
14931 }
14932 }
14933
14934
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(guyversion < 8)
14935 {
14936 if(i == eGLEEOK1 || i == eGLEEOK2 || i == eGLEEOK3 || i == eGLEEOK4 || i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14937 {
14938 // Some of these are deliberately different to NewDefault/defdata.cpp, by the way. -L
14939 tempguy.misc5 = 4; //neck length in segments
14940 tempguy.misc6 = 8; //neck offset from first body tile
14941 tempguy.misc7 = 40; //offset for each subsequent neck tile from the first neck tile
14942 tempguy.misc8 = 168; //head offset from first body tile
14943 tempguy.misc9 = 228; //flying head offset from first body tile
14944
14945 if(i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14946 {
14947 tempguy.misc6 += 10; //neck offset from first body tile
14948 tempguy.misc8 -= 12; //head offset from first body tile
14949 }
14950 }
14951 }
14952
14953
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(guyversion < 10) // December 2007 - Dodongo CSet fix
14954 {
14955 if(get_bit(deprecated_rules,46) && tempguy.family==eeDONGO && tempguy.misc1==0)
14956 tempguy.bosspal = spDIG;
14957 }
14958
14959
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(guyversion < 11) // December 2007 - Spinning Tile fix
14960 {
14961 if(tempguy.family==eeSPINTILE)
14962 {
14963 tempguy.flags |= guy_superman;
14964 tempguy.item_set = 0; // Don't drop items
14965 tempguy.step = 300;
14966 }
14967 }
14968
14969
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(guyversion < 12) // October 2008 - Flashing Bubble, Rope 2, and Ghini 2 fix
14970 {
14971 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
14972 {
14973 if(tempguy.family==eeROPE)
14974 {
14975 tempguy.flags2 &= ~guy_flashing;
14976 }
14977 }
14978
14979 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
14980 {
14981 if(tempguy.family==eeBUBBLE)
14982 {
14983 tempguy.flags2 &= ~guy_flashing;
14984 }
14985 }
14986
14987 if((tempguy.family==eeGHINI)&&(tempguy.misc1))
14988 {
14989 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
14990 {
14991 tempguy.flags2 |= guy_blinking;
14992 }
14993
14994 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
14995 {
14996 tempguy.flags2 |= guy_transparent;
14997 }
14998 }
14999 }
15000
15001
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(guyversion < 15) // July 2009 - Guy Fire and Fairy fix
15002 {
15003 if(i==gFIRE)
15004 {
15005 tempguy.e_anim = aFLIP;
15006 tempguy.e_frate = 24;
15007 }
15008
15009 if(i==gFAIRY)
15010 {
15011 tempguy.e_anim = a2FRM;
15012 tempguy.e_frate = 16;
15013 }
15014 }
15015
15016
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(guyversion < 16) // November 2009 - Super Enemy Editor part 1
15017 {
15018 if(i==0) Z_message("Updating guys to version 16...\n");
15019
15020 update_guy_1(&tempguy);
15021
15022 if(i==eMPOLSV)
15023 {
15024 tempguy.defense[edefARROW] = edCHINK;
15025 tempguy.defense[edefMAGIC] = ed1HKO;
15026 tempguy.defense[edefREFMAGIC] = ed1HKO;
15027 }
15028 }
15029
15030
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(guyversion < 17) // December 2009
15031 {
15032 if(tempguy.family==eePROJECTILE)
15033 {
15034 tempguy.misc1 = 0;
15035 }
15036 }
15037
15038
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(guyversion < 18) // January 2010
15039 {
15040 bool boss = (tempguy.family == eeAQUA || tempguy.family==eeDONGO || tempguy.family == eeMANHAN || tempguy.family == eeGHOMA || tempguy.family==eeDIG
15041 || tempguy.family == eeGLEEOK || tempguy.family==eePATRA || tempguy.family == eeGANON || tempguy.family==eeMOLD);
15042
15043 tempguy.hitsfx = (boss && tempguy.family != eeMOLD && tempguy.family != eeDONGO && tempguy.family != eeDIG) ? WAV_GASP : 0;
15044 tempguy.deadsfx = (boss && (tempguy.family != eeDIG || tempguy.misc10 == 0)) ? WAV_GASP : WAV_EDEAD;
15045
15046 if(tempguy.family == eeAQUA)
15047 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eRAQUAM].defense[j];
15048 else if(tempguy.family == eeMANHAN)
15049 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eMANHAN].defense[j];
15050 else if(tempguy.family==eePATRA)
15051 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
15052 else if(tempguy.family==eeGHOMA)
15053 {
15054 for(int32_t j=0; j<edefLAST; j++)
15055 tempguy.defense[j] = default_guys[eGOHMA1].defense[j];
15056
15057 tempguy.defense[edefARROW] = ((tempguy.misc1==3) ? edCHINKL8 : (tempguy.misc1==2) ? edCHINKL4 : 0);
15058
15059 if(tempguy.misc1==3 && !tempguy.weapon) tempguy.weapon = ewFlame;
15060
15061 tempguy.misc1--;
15062 }
15063 else if(tempguy.family == eeGLEEOK)
15064 {
15065 for(int32_t j=0; j<edefLAST; j++)
15066 tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
15067
15068 if(tempguy.misc3==1 && !tempguy.weapon) tempguy.weapon = ewFlame;
15069 }
15070 else if(tempguy.family == eeARMOS)
15071 {
15072 tempguy.family=eeWALK;
15073 tempguy.hrate = 0;
15074 tempguy.misc10 = tempguy.misc1;
15075 tempguy.misc1 = tempguy.misc2 = tempguy.misc3 = tempguy.misc4 = tempguy.misc5 = tempguy.misc6 = tempguy.misc7 = tempguy.misc8 = 0;
15076 tempguy.misc9 = e9tARMOS;
15077 }
15078 else if(tempguy.family == eeGHINI && !tempguy.misc1)
15079 {
15080 tempguy.family=eeWALK;
15081 tempguy.hrate = 0;
15082 tempguy.misc1 = tempguy.misc2 = tempguy.misc3 = tempguy.misc4 = tempguy.misc5 = tempguy.misc6 =
15083 tempguy.misc7 = tempguy.misc8 = tempguy.misc9 = tempguy.misc10 = 0;
15084 }
15085
15086 // Spawn animation flags
15087 if(tempguy.family == eeWALK && (tempguy.flags2&cmbflag_armos || tempguy.flags2&cmbflag_ghini))
15088 tempguy.flags |= guy_fadeflicker;
15089 else
15090 tempguy.flags &= 0x0F00000F; // Get rid of the unused flags!
15091 }
15092
15093
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(guyversion < 20) // April 2010
15094 {
15095 if(tempguy.family == eeTRAP)
15096 {
15097 tempguy.misc2 = tempguy.misc10;
15098
15099 if(tempguy.misc10>=1)
15100 {
15101 tempguy.misc1++;
15102 }
15103
15104 tempguy.misc10 = 0;
15105 }
15106
15107 // Bomb Blast fix
15108 if(tempguy.weapon==ewBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.misc2 != e2tBOMBCHU))
15109 tempguy.weapon = ewLitBomb;
15110 else if(tempguy.weapon==ewSBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.misc2 != e2tBOMBCHU))
15111 tempguy.weapon = ewLitSBomb;
15112 }
15113
15114
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(guyversion < 21) // September 2011
15115 {
15116 if(tempguy.family == eeKEESE || tempguy.family == eeKEESETRIB)
15117 {
15118 if(tempguy.family == eeKEESETRIB)
15119 {
15120 tempguy.family = eeKEESE;
15121 tempguy.misc2 = e2tKEESETRIB;
15122 tempguy.misc1 = 0;
15123 }
15124
15125 tempguy.rate = 2;
15126 tempguy.hrate = 8;
15127 tempguy.homing = 0;
15128 tempguy.step= (tempguy.family == eeKEESE && tempguy.misc1 ? 100:62);
15129 }
15130 else if(tempguy.family == eePEAHAT || tempguy.family==eePATRA)
15131 {
15132 if(tempguy.family == eePEAHAT)
15133 {
15134 tempguy.rate = 4;
15135 tempguy.step = 62;
15136 }
15137 else
15138 tempguy.step = 25;
15139
15140 tempguy.hrate = 8;
15141 tempguy.homing = 0;
15142 }
15143 else if(tempguy.family == eeDIG || tempguy.family == eeMANHAN)
15144 {
15145 if(tempguy.family == eeMANHAN)
15146 tempguy.step=50;
15147
15148 tempguy.hrate = 16;
15149 tempguy.homing = 0;
15150 }
15151 else if(tempguy.family == eeGLEEOK)
15152 {
15153 tempguy.rate = 2;
15154 tempguy.homing = 0;
15155 tempguy.hrate = 9;
15156 tempguy.step=89;
15157 }
15158 else if(tempguy.family == eeGHINI)
15159 {
15160 tempguy.rate = 4;
15161 tempguy.hrate = 12;
15162 tempguy.step=62;
15163 tempguy.homing = 0;
15164 }
15165
15166 // Bigdig random rate fix
15167 if(tempguy.family==eeDIG && tempguy.misc10==1)
15168 {
15169 tempguy.rate = 2;
15170 }
15171 }
15172
15173
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(guyversion < 24) // November 2012
15174 {
15175 if(tempguy.family==eeLANM)
15176 tempguy.misc3 = 1;
15177 else if(tempguy.family==eeMOLD)
15178 tempguy.misc2 = 0;
15179 }
15180
15181
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 37888 times.
49152 if(guyversion < 33) //Whistle defence did not exist before this version of 2.54. -Z
15182 {
15183
2/2
✓ Branch 0 taken 647 times.
✓ Branch 1 taken 37241 times.
37888 if(tempguy.family!=eeDIG)
15184 {
15185 37241 tempguy.defense[edefWhistle] = edIGNORE; //Might need to be ignore, universally.
15186 37241 }
15187
15188 37888 }
15189 // does not seem to solve the issue!
15190
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if ( Header->zelda_version <= 0x210 )
15191 {
15192 al_trace("Detected version %d for dodongo patch.\n",Header->zelda_version);
15193 if ( tempguy.family == eeDONGO )
15194 {
15195 tempguy.deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
15196 }
15197 }
15198
15199
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 37888 times.
49152 if(guyversion >= 42)
15200 {
15201
2/2
✓ Branch 0 taken 10240 times.
✓ Branch 1 taken 1024 times.
11264 if(guyversion >= 47)
15202 {
15203
1/2
✓ Branch 0 taken 10240 times.
✗ Branch 1 not taken.
10240 if(!p_igetl(&(tempguy.moveflags),f,keepdata))
15204 {
15205 return qe_invalid;
15206 }
15207 10240 }
15208 else
15209 {
15210 byte fl;
15211
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_getc(&fl,f,keepdata))
15212 {
15213 return qe_invalid;
15214 }
15215 1024 tempguy.moveflags = fl;
15216 }
15217 11264 }
15218 else
15219 {
15220
7/8
✓ Branch 0 taken 142 times.
✓ Branch 1 taken 29895 times.
✓ Branch 2 taken 1177 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 507 times.
✓ Branch 5 taken 271 times.
✓ Branch 6 taken 234 times.
✓ Branch 7 taken 5662 times.
37888 switch(tempguy.family)
15221 {
15222 //No gravity; floats over pits
15223 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
15224 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
15225 //Special (bosses, etc)
15226 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
15227 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
15228 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
15229 29895 tempguy.moveflags = FLAG_CAN_PITWALK;
15230 29895 break;
15231 //No gravity, but falls in pits
15232 case eeLEV:
15233 507 tempguy.moveflags = FLAG_CAN_PITFALL;
15234 507 break;
15235 //Bosses that respect pits
15236 case eeDONGO:
15237 271 tempguy.moveflags = FLAG_OBEYS_GRAV;
15238 271 break;
15239 case eeLANM:
15240 234 tempguy.moveflags = 0;
15241 234 break;
15242 //Gravity, floats over pits
15243 case eeWIZZ: case eeWALLM: case eeGHINI:
15244 1177 tempguy.moveflags = FLAG_OBEYS_GRAV | FLAG_CAN_PITWALK;
15245 1177 break;
15246 //Gravity and falls in pits
15247 case eeWALK:
15248
4/4
✓ Branch 0 taken 5349 times.
✓ Branch 1 taken 313 times.
✓ Branch 2 taken 275 times.
✓ Branch 3 taken 5074 times.
5662 if (tempguy.misc9==e9tPOLSVOICE||tempguy.misc9==e9tVIRE)
15249 588 break;
15250 [[fallthrough]];
15251 case eeOTHER:
15252 case eeSCRIPT01: case eeSCRIPT02: case eeSCRIPT03: case eeSCRIPT04: case eeSCRIPT05:
15253 case eeSCRIPT06: case eeSCRIPT07: case eeSCRIPT08: case eeSCRIPT09: case eeSCRIPT10:
15254 case eeSCRIPT11: case eeSCRIPT12: case eeSCRIPT13: case eeSCRIPT14: case eeSCRIPT15:
15255 case eeSCRIPT16: case eeSCRIPT17: case eeSCRIPT18: case eeSCRIPT19: case eeSCRIPT20:
15256 case eeFFRIENDLY01: case eeFFRIENDLY02: case eeFFRIENDLY03: case eeFFRIENDLY04: case eeFFRIENDLY05:
15257 case eeFFRIENDLY06: case eeFFRIENDLY07: case eeFFRIENDLY08: case eeFFRIENDLY09: case eeFFRIENDLY10:
15258 5216 tempguy.moveflags = FLAG_OBEYS_GRAV | FLAG_CAN_PITFALL;
15259 5216 }
15260 }
15261
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 37888 times.
49152 if(guyversion < 43)
15262 {
15263
2/2
✓ Branch 0 taken 31072 times.
✓ Branch 1 taken 6816 times.
37888 switch(tempguy.family)
15264 {
15265 //No gravity; floats over pits
15266 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
15267 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
15268 //Special (bosses, etc)
15269 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
15270 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
15271 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
15272 case eeWIZZ: case eeWALLM: case eeGHINI:
15273 //Gravity, floats over pits
15274 31072 tempguy.moveflags |= FLAG_CAN_WATERWALK;
15275 31072 break;
15276 }
15277 37888 }
15278
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 37888 times.
49152 if (guyversion < 44)
15279 {
15280
2/2
✓ Branch 0 taken 37527 times.
✓ Branch 1 taken 361 times.
37888 if ( tempguy.family == eeGHOMA )
15281 {
15282 361 tempguy.flags |= guy_fadeinstant;
15283 361 }
15284 37888 }
15285
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 37888 times.
49152 if (guyversion > 44)
15286 {
15287
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_getc(&(tempguy.spr_shadow),f,keepdata))
15288 {
15289 return qe_invalid;
15290 }
15291
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_getc(&(tempguy.spr_death),f,keepdata))
15292 {
15293 return qe_invalid;
15294 }
15295
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_getc(&(tempguy.spr_spawn),f,keepdata))
15296 {
15297 return qe_invalid;
15298 }
15299 11264 }
15300 else
15301 {
15302
2/2
✓ Branch 0 taken 37740 times.
✓ Branch 1 taken 148 times.
37888 tempguy.spr_shadow = (tempguy.family==eeROCK && tempguy.misc10==1) ? iwLargeShadow : iwShadow;
15303 37888 tempguy.spr_death = iwDeath;
15304 37888 tempguy.spr_spawn = iwSpawn;
15305 }
15306
15307
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 37888 times.
49152 if(guyversion < 46)
15308 {
15309
4/4
✓ Branch 0 taken 5662 times.
✓ Branch 1 taken 32226 times.
✓ Branch 2 taken 5349 times.
✓ Branch 3 taken 313 times.
37888 if(tempguy.family == eeWALK && tempguy.misc9 == e9tPOLSVOICE)
15310 {
15311 313 tempguy.moveflags |= FLAG_CAN_WATERWALK;
15312 313 }
15313 37888 }
15314
15315
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49152 times.
49152 if(keepdata)
15316 {
15317 49152 guysbuf[i] = tempguy;
15318 49152 }
15319 49152 }
15320 96 }
15321
15322 96 return 0;
15323 99 }
15324
15325 void update_guy_1(guydata *tempguy) // November 2009
15326 {
15327 bool doesntcount = false;
15328 tempguy->flags &= ~weak_arrow; // Formerly 'weak to arrow' which wasn't implemented
15329
15330 switch(tempguy->family)
15331 {
15332 case 1: //eeWALK
15333 switch(tempguy->misc10)
15334 {
15335 case 0: //Stalfos
15336 if(tempguy->misc1==1) // Fires four projectiles at once
15337 tempguy->misc1=4;
15338
15339 break;
15340
15341 case 1: //Darknut
15342 goto darknuts;
15343 break;
15344 }
15345
15346 tempguy->misc10 = 0;
15347 break;
15348
15349 case 2: //eeSHOOT
15350 tempguy->family = eeWALK;
15351
15352 switch(tempguy->misc10)
15353 {
15354 case 0: //Octorok
15355 if(tempguy->misc1==1||tempguy->misc1==2)
15356 {
15357 tempguy->misc1=e1tFIREOCTO;
15358 tempguy->misc2=e2tFIREOCTO;
15359 }
15360 else tempguy->misc1 = 0;
15361
15362 tempguy->misc6=tempguy->misc4;
15363 tempguy->misc4=tempguy->misc3;
15364 tempguy->misc3=0;
15365 break;
15366
15367 case 1: // Moblin
15368 tempguy->misc1 = 0;
15369 break;
15370
15371 case 2: //Lynel
15372 tempguy->misc6=tempguy->misc1+1;
15373 tempguy->misc1=0;
15374 break;
15375
15376 case 3: //Stalfos 2
15377 if(tempguy->misc1==1) // Fires four projectiles at once
15378 tempguy->misc1=e1t4SHOTS;
15379 else tempguy->misc1 = 0;
15380
15381 break;
15382
15383 case 4: //Darknut 5
15384 darknuts:
15385 tempguy->defense[edefFIRE] = edIGNORE;
15386 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15387 tempguy->defense[edefHOOKSHOT] = 0;
15388 tempguy->defense[edefARROW] = tempguy->defense[edefBYRNA] = tempguy->defense[edefREFROCK] =
15389 tempguy->defense[edefMAGIC] = tempguy->defense[edefSTOMP] = edCHINK;
15390
15391 if(tempguy->misc1==1)
15392 tempguy->misc1=2;
15393 else if(tempguy->misc1==2)
15394 {
15395 tempguy->misc4=tempguy->misc3;
15396 tempguy->misc3=tempguy->misc2;
15397 tempguy->misc2=e2tSPLIT;
15398 tempguy->misc1 = 0;
15399 }
15400 else tempguy->misc1 = 0;
15401
15402 tempguy->flags |= inv_front;
15403
15404 if(get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
15405 tempguy->flags |= guy_bkshield;
15406
15407 break;
15408 }
15409
15410 tempguy->misc10 = 0;
15411 break;
15412
15413 /*
15414 case 9: //eeARMOS
15415 tempguy->family = eeWALK;
15416 break;
15417 */
15418 case 11: //eeGEL
15419 case 33: //eeGELTRIB
15420 if(tempguy->family==33)
15421 {
15422 tempguy->misc4 = 1;
15423
15424 if(get_bit(deprecated_rules, qr_OLDTRIBBLES_DEP)) //Old Tribbles
15425 tempguy->misc3 = tempguy->misc2;
15426
15427 tempguy->misc2 = e2tTRIBBLE;
15428 }
15429 else
15430 {
15431 tempguy->misc4 = 0;
15432 tempguy->misc3 = 0;
15433 tempguy->misc2 = 0;
15434 }
15435
15436 tempguy->family = eeWALK;
15437
15438 if(tempguy->misc1)
15439 {
15440 tempguy->misc1=1;
15441 tempguy->weapon = ewFireTrail;
15442 }
15443
15444 break;
15445
15446 case 34: //eeZOLTRIB
15447 case 12: //eeZOL
15448 tempguy->misc4=tempguy->misc3;
15449 tempguy->misc3=tempguy->misc2;
15450 tempguy->family = eeWALK;
15451 tempguy->misc2=e2tSPLITHIT;
15452
15453 if(tempguy->misc1)
15454 {
15455 tempguy->misc1=1;
15456 tempguy->weapon = ewFireTrail;
15457 }
15458
15459 break;
15460
15461 case 13: //eeROPE
15462 tempguy->family = eeWALK;
15463 tempguy->misc9 = e9tROPE;
15464
15465 if(tempguy->misc1)
15466 {
15467 tempguy->misc4 = tempguy->misc3;
15468 tempguy->misc3 = tempguy->misc2;
15469 tempguy->misc2 = e2tBOMBCHU;
15470 }
15471
15472 tempguy->misc1 = 0;
15473 break;
15474
15475 case 14: //eeGORIYA
15476 tempguy->family = eeWALK;
15477
15478 if(tempguy->misc1!=2) tempguy->misc1 = 0;
15479
15480 break;
15481
15482 case 17: //eeBUBBLE
15483 tempguy->family = eeWALK;
15484 tempguy->misc8 = tempguy->misc2;
15485 tempguy->misc7 = tempguy->misc1 + 1;
15486 tempguy->misc1 = tempguy->misc2 = 0;
15487
15488 //fallthrogh
15489 case eeTRAP:
15490 case eeROCK:
15491 doesntcount = true;
15492 break;
15493
15494 case 35: //eeVIRETRIB
15495 case 18: //eeVIRE
15496 tempguy->family = eeWALK;
15497 tempguy->misc4=tempguy->misc3;
15498 tempguy->misc3=tempguy->misc2;
15499 tempguy->misc2=e2tSPLITHIT;
15500 tempguy->misc9=e9tVIRE;
15501 break;
15502
15503 case 19: //eeLIKE
15504 tempguy->family = eeWALK;
15505 tempguy->misc7 = e7tEATITEMS;
15506 tempguy->misc8=95;
15507 break;
15508
15509 case 20: //eePOLSV
15510 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15511 tempguy->defense[edefBOMB] = tempguy->defense[edefSBOMB] = tempguy->defense[edefFIRE] = edIGNORE;
15512 tempguy->defense[edefMAGIC] = tempguy->defense[edefBYRNA] = edCHINK;
15513 tempguy->defense[edefARROW] = ed1HKO;
15514 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15515 tempguy->family = eeWALK;
15516 tempguy->misc9 = e9tPOLSVOICE;
15517 tempguy->rate = 4;
15518 tempguy->homing = 32;
15519 tempguy->hrate = 10;
15520 tempguy->grumble = 0;
15521 break;
15522
15523 case eeWIZZ:
15524 if(tempguy->misc4)
15525 {
15526 for(int32_t i=0; i < edefLAST; i++)
15527 tempguy->defense[i] = (i != edefREFBEAM && i != edefREFMAGIC && i != edefQUAKE) ? edIGNORE : 0;
15528 }
15529 else
15530 {
15531 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15532 tempguy->defense[edefMAGIC] = edCHINK;
15533 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15534 tempguy->defense[edefARROW] = tempguy->defense[edefFIRE] =
15535 tempguy->defense[edefWAND] = tempguy->defense[edefBYRNA] = edIGNORE;
15536 }
15537
15538 break;
15539
15540 case eePEAHAT:
15541 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15542
15543 if(!(tempguy->flags & guy_bhit))
15544 tempguy->defense[edefBRANG] = edSTUNONLY;
15545
15546 break;
15547
15548 case eeLEV:
15549 tempguy->defense[edefSTOMP] = edCHINK;
15550 break;
15551 }
15552
15553 // Old flags
15554 if(tempguy->flags & guy_superman)
15555 {
15556 for(int32_t i = 0; i < edefLAST; i++)
15557 if(!(i==edefSBOMB && (tempguy->flags & guy_sbombonly)))
15558 tempguy->defense[i] = (i==edefBRANG && tempguy->defense[i] != edIGNORE
15559 && tempguy->family != eeROCK && tempguy->family != eeTRAP
15560 && tempguy->family != eePROJECTILE) ? edSTUNORIGNORE : edIGNORE;
15561 }
15562
15563 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15564
15565 if(doesntcount)
15566 tempguy->flags |= (guy_doesntcount);
15567 }
15568
15569
15570 144976 int32_t readmapscreen_old(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, zcmap *temp_map, word version)
15571 {
15572 byte tempbyte, padding;
15573 int32_t extras, secretcombos;
15574 //al_trace("readmapscreen Header->zelda_version: %x\n",Header->zelda_version);
15575
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
144976 if(!p_getc(&(temp_mapscr->valid),f,true))
15576 {
15577 return qe_invalid;
15578 }
15579
15580
15581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
144976 if(!p_getc(&(temp_mapscr->guy),f,true))
15582 {
15583 return qe_invalid;
15584 }
15585
15586
2/6
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 144976 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<146)))
15587 {
15588 if(!p_getc(&tempbyte,f,true))
15589 {
15590 return qe_invalid;
15591 }
15592
15593 temp_mapscr->str=tempbyte;
15594 }
15595 else
15596 {
15597
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
144976 if(!p_igetw(&(temp_mapscr->str),f,true))
15598 {
15599 return qe_invalid;
15600 }
15601 }
15602
15603
1/2
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
144976 if(!p_getc(&(temp_mapscr->room),f,true))
15604 {
15605 return qe_invalid;
15606 }
15607
15608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
144976 if(!p_getc(&(temp_mapscr->item),f,true))
15609 {
15610 return qe_invalid;
15611 }
15612
15613
3/6
✓ Branch 0 taken 133960 times.
✓ Branch 1 taken 11016 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 133960 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if(Header->zelda_version < 0x211 || (Header->zelda_version == 0x211 && Header->build < 14))
15614 {
15615 11016 temp_mapscr->hasitem = (temp_mapscr->item != 0) ? 1 : 0;
15616 11016 }
15617 else
15618 {
15619
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133960 times.
133960 if(!p_getc(&(temp_mapscr->hasitem),f,true))
15620 return qe_invalid;
15621 }
15622
15623
1/4
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
144976 if((Header->zelda_version < 0x192)||
15624
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
144976 ((Header->zelda_version == 0x192)&&(Header->build<154)))
15625 {
15626 if(!p_getc(&tempbyte,f,true))
15627 {
15628 return qe_invalid;
15629 }
15630 }
15631
15632
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
144976 if(!p_getc(&(temp_mapscr->tilewarptype[0]),f,true))
15633 {
15634 return qe_invalid;
15635 }
15636
15637
1/2
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
144976 if(Header->zelda_version < 0x193)
15638 {
15639 if(!p_getc(&tempbyte,f,true))
15640 {
15641 return qe_invalid;
15642 }
15643 }
15644
15645
3/6
✓ Branch 0 taken 11016 times.
✓ Branch 1 taken 133960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11016 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15646 {
15647
2/2
✓ Branch 0 taken 401880 times.
✓ Branch 1 taken 133960 times.
535840 for(int32_t i=1; i<4; i++)
15648 {
15649
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 401880 times.
401880 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f,true))
15650 {
15651 return qe_invalid;
15652 }
15653 401880 }
15654 133960 }
15655 else
15656 {
15657 11016 temp_mapscr->tilewarptype[1]=0;
15658 11016 temp_mapscr->tilewarptype[2]=0;
15659 11016 temp_mapscr->tilewarptype[3]=0;
15660 }
15661
15662
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
15663 {
15664
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
144976 if(!p_igetw(&(temp_mapscr->door_combo_set),f,true))
15665 {
15666 return qe_invalid;
15667 }
15668 144976 }
15669
15670
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
144976 if(!p_getc(&(temp_mapscr->warpreturnx[0]),f,true))
15671 {
15672 return qe_invalid;
15673 }
15674
15675 144976 temp_mapscr->warpreturnx[1]=0;
15676 144976 temp_mapscr->warpreturnx[2]=0;
15677 144976 temp_mapscr->warpreturnx[3]=0;
15678
15679
3/6
✓ Branch 0 taken 11016 times.
✓ Branch 1 taken 133960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11016 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15680 {
15681
2/2
✓ Branch 0 taken 401880 times.
✓ Branch 1 taken 133960 times.
535840 for(int32_t i=1; i<4; i++)
15682 {
15683
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 401880 times.
401880 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f,true))
15684 {
15685 return qe_invalid;
15686 }
15687 401880 }
15688 133960 }
15689
15690
1/2
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
144976 if(!p_getc(&(temp_mapscr->warpreturny[0]),f,true))
15691 {
15692 return qe_invalid;
15693 }
15694
15695 144976 temp_mapscr->warpreturny[1]=0;
15696 144976 temp_mapscr->warpreturny[2]=0;
15697 144976 temp_mapscr->warpreturny[3]=0;
15698
15699
3/6
✓ Branch 0 taken 11016 times.
✓ Branch 1 taken 133960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11016 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15700 {
15701
2/2
✓ Branch 0 taken 401880 times.
✓ Branch 1 taken 133960 times.
535840 for(int32_t i=1; i<4; i++)
15702 {
15703
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 401880 times.
401880 if(!p_getc(&(temp_mapscr->warpreturny[i]),f,true))
15704 {
15705 return qe_invalid;
15706 }
15707 401880 }
15708
15709
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(version>=18)
15710 {
15711
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(!p_igetw(&temp_mapscr->warpreturnc,f,true))
15712 {
15713 return qe_invalid;
15714 }
15715 133960 }
15716 else
15717 {
15718 byte temp;
15719
15720 if(!p_getc(&temp,f,true))
15721 {
15722 return qe_invalid;
15723 }
15724
15725 temp_mapscr->warpreturnc=temp<<8|temp;
15726 }
15727 133960 }
15728
15729
1/2
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
144976 if(!p_getc(&(temp_mapscr->stairx),f,true))
15730
15731 {
15732 return qe_invalid;
15733 }
15734
15735
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
144976 if(!p_getc(&(temp_mapscr->stairy),f,true))
15736 {
15737 return qe_invalid;
15738 }
15739
15740
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
144976 if(!p_getc(&(temp_mapscr->itemx),f,true))
15741 {
15742 return qe_invalid;
15743 }
15744
15745
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
144976 if(!p_getc(&(temp_mapscr->itemy),f,true))
15746 {
15747 return qe_invalid;
15748 }
15749
15750
2/2
✓ Branch 0 taken 133960 times.
✓ Branch 1 taken 11016 times.
144976 if(version > 15) // February 2009
15751 {
15752
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(!p_igetw(&(temp_mapscr->color),f,true))
15753 {
15754 return qe_invalid;
15755 }
15756 133960 }
15757 else
15758 {
15759
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11016 times.
11016 if(!p_getc(& tempbyte,f,true))
15760 {
15761 return qe_invalid;
15762 }
15763
15764 11016 temp_mapscr->color = (word) tempbyte;
15765 }
15766
15767
1/2
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
144976 if(!p_getc(&(temp_mapscr->enemyflags),f,true))
15768 {
15769 return qe_invalid;
15770 }
15771
15772
2/2
✓ Branch 0 taken 579904 times.
✓ Branch 1 taken 144976 times.
724880 for(int32_t k=0; k<4; k++)
15773 {
15774
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 579904 times.
579904 if(!p_getc(&(temp_mapscr->door[k]),f,true))
15775 {
15776 return qe_invalid;
15777
15778 }
15779 579904 }
15780
15781
2/2
✓ Branch 0 taken 11016 times.
✓ Branch 1 taken 133960 times.
144976 if(version <= 11)
15782 {
15783
1/2
✓ Branch 0 taken 11016 times.
✗ Branch 1 not taken.
11016 if(!p_getc(&(tempbyte),f,true))
15784 {
15785 return qe_invalid;
15786 }
15787
15788 11016 temp_mapscr->tilewarpdmap[0]=(word)tempbyte;
15789
15790
2/6
✓ Branch 0 taken 11016 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11016 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
11016 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15791 {
15792 for(int32_t i=1; i<4; i++)
15793 {
15794 if(!p_getc(&(tempbyte),f,true))
15795 {
15796 return qe_invalid;
15797 }
15798
15799 temp_mapscr->tilewarpdmap[i]=(word)tempbyte;
15800 }
15801 }
15802 else
15803 {
15804 11016 temp_mapscr->tilewarpdmap[1]=0;
15805 11016 temp_mapscr->tilewarpdmap[2]=0;
15806 11016 temp_mapscr->tilewarpdmap[3]=0;
15807 }
15808 11016 }
15809 else
15810 {
15811
2/2
✓ Branch 0 taken 535840 times.
✓ Branch 1 taken 133960 times.
669800 for(int32_t i=0; i<4; i++)
15812 {
15813
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 535840 times.
535840 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f,true))
15814 {
15815 return qe_invalid;
15816 }
15817 535840 }
15818 }
15819
15820
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
144976 if(!p_getc(&(temp_mapscr->tilewarpscr[0]),f,true))
15821 {
15822 return qe_invalid;
15823 }
15824
15825
3/6
✓ Branch 0 taken 11016 times.
✓ Branch 1 taken 133960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11016 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15826 {
15827
2/2
✓ Branch 0 taken 401880 times.
✓ Branch 1 taken 133960 times.
535840 for(int32_t i=1; i<4; i++)
15828 {
15829
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 401880 times.
401880 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f,true))
15830 {
15831 return qe_invalid;
15832 }
15833 401880 }
15834 133960 }
15835 else
15836 {
15837 11016 temp_mapscr->tilewarpscr[1]=0;
15838 11016 temp_mapscr->tilewarpscr[2]=0;
15839 11016 temp_mapscr->tilewarpscr[3]=0;
15840 }
15841
15842
2/2
✓ Branch 0 taken 133960 times.
✓ Branch 1 taken 11016 times.
144976 if(version >= 15)
15843 {
15844
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133960 times.
133960 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f,true))
15845 {
15846 return qe_invalid;
15847 }
15848 133960 }
15849 else
15850 {
15851 11016 temp_mapscr->tilewarpoverlayflags=0;
15852 }
15853
15854
1/2
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
144976 if(!p_getc(&(temp_mapscr->exitdir),f,true))
15855 {
15856 return qe_invalid;
15857 }
15858
15859
1/2
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
144976 if(Header->zelda_version < 0x193)
15860 {
15861 if(!p_getc(&tempbyte,f,true))
15862 {
15863 return qe_invalid;
15864 }
15865
15866 }
15867
15868
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version == 0x192)&&(Header->build>145)&&(Header->build<154))
15869 {
15870 if(!p_getc(&padding,f,true))
15871 {
15872 return qe_invalid;
15873 }
15874 }
15875
15876
2/2
✓ Branch 0 taken 1449760 times.
✓ Branch 1 taken 144976 times.
1594736 for(int32_t k=0; k<10; k++)
15877 {
15878 /*
15879 if (!temp_mapscr->enemy[k])
15880 {
15881 continue;
15882 }
15883 */
15884
2/6
✓ Branch 0 taken 1449760 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1449760 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1449760 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<10)))
15885 {
15886 if(!p_getc(&tempbyte,f,true))
15887 {
15888 return qe_invalid;
15889 }
15890
15891 temp_mapscr->enemy[k]=tempbyte;
15892 }
15893 else
15894 {
15895
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1449760 times.
1449760 if(!p_igetw(&(temp_mapscr->enemy[k]),f,true))
15896 {
15897 return qe_invalid;
15898 }
15899 }
15900
15901
2/6
✓ Branch 0 taken 1449760 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1449760 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1449760 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<108)))
15902 {
15903 //using enumerations here is dangerous
15904 //very easy to break old quests -DD
15905 if(temp_mapscr->enemy[k]>=57) //old eGOHMA1
15906 {
15907 temp_mapscr->enemy[k]+=5;
15908 }
15909 else if(temp_mapscr->enemy[k]>=52) //old eGLEEOK2
15910 {
15911 temp_mapscr->enemy[k]+=1;
15912 }
15913 }
15914
15915
2/2
✓ Branch 0 taken 1339600 times.
✓ Branch 1 taken 110160 times.
1449760 if(version < 9)
15916 {
15917
2/2
✓ Branch 0 taken 102675 times.
✓ Branch 1 taken 7485 times.
110160 if(temp_mapscr->enemy[k]>0)
15918 {
15919 7485 temp_mapscr->enemy[k]+=10;
15920 7485 }
15921 110160 }
15922 //don't read in any invalid data
15923
1/2
✓ Branch 0 taken 1449760 times.
✗ Branch 1 not taken.
1449760 if ( ((unsigned)temp_mapscr->enemy[k]) > MAXGUYS )
15924 {
15925 al_trace("Tried to read an invalid enemy ID (%d) for tmpscr->enemy[%d]. This has been cleared to 0.\n", temp_mapscr->enemy[k], k);
15926 temp_mapscr->enemy[k] = 0;
15927 }
15928 1449760 }
15929
15930
1/2
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
144976 if(!p_getc(&(temp_mapscr->pattern),f,true))
15931 {
15932 return qe_invalid;
15933 }
15934
15935
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
144976 if(!p_getc(&(temp_mapscr->sidewarptype[0]),f,true))
15936 {
15937 return qe_invalid;
15938 }
15939
15940
3/6
✓ Branch 0 taken 11016 times.
✓ Branch 1 taken 133960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11016 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15941 {
15942
2/2
✓ Branch 0 taken 401880 times.
✓ Branch 1 taken 133960 times.
535840 for(int32_t i=1; i<4; i++)
15943 {
15944
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 401880 times.
401880 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f,true))
15945 {
15946 return qe_invalid;
15947 }
15948 401880 }
15949 133960 }
15950 else
15951 {
15952 11016 temp_mapscr->sidewarptype[1]=0;
15953 11016 temp_mapscr->sidewarptype[2]=0;
15954 11016 temp_mapscr->sidewarptype[3]=0;
15955 }
15956
15957
2/2
✓ Branch 0 taken 133960 times.
✓ Branch 1 taken 11016 times.
144976 if(version >= 15)
15958 {
15959
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f,true))
15960 {
15961 return qe_invalid;
15962 }
15963 133960 }
15964 else
15965 {
15966 11016 temp_mapscr->sidewarpoverlayflags=0;
15967 }
15968
15969
1/2
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
144976 if(!p_getc(&(temp_mapscr->warparrivalx),f,true))
15970 {
15971 return qe_invalid;
15972 }
15973
15974
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
144976 if(!p_getc(&(temp_mapscr->warparrivaly),f,true))
15975 {
15976 return qe_invalid;
15977 }
15978
15979
2/2
✓ Branch 0 taken 579904 times.
✓ Branch 1 taken 144976 times.
724880 for(int32_t k=0; k<4; k++)
15980 {
15981
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 579904 times.
579904 if(!p_getc(&(temp_mapscr->path[k]),f,true))
15982 {
15983 return qe_invalid;
15984 }
15985 579904 }
15986
15987
1/2
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
144976 if(!p_getc(&(temp_mapscr->sidewarpscr[0]),f,true))
15988 {
15989 return qe_invalid;
15990 }
15991
15992
3/6
✓ Branch 0 taken 11016 times.
✓ Branch 1 taken 133960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11016 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15993 {
15994
2/2
✓ Branch 0 taken 133960 times.
✓ Branch 1 taken 401880 times.
535840 for(int32_t i=1; i<4; i++)
15995 {
15996
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 401880 times.
401880 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f,true))
15997 {
15998 return qe_invalid;
15999 }
16000 401880 }
16001 133960 }
16002 else
16003 {
16004 11016 temp_mapscr->sidewarpscr[1]=0;
16005 11016 temp_mapscr->sidewarpscr[2]=0;
16006 11016 temp_mapscr->sidewarpscr[3]=0;
16007 }
16008
16009
2/2
✓ Branch 0 taken 11016 times.
✓ Branch 1 taken 133960 times.
144976 if(version <= 11)
16010 {
16011
1/2
✓ Branch 0 taken 11016 times.
✗ Branch 1 not taken.
11016 if(!p_getc(&(tempbyte),f,true))
16012 {
16013 return qe_invalid;
16014 }
16015
16016 11016 temp_mapscr->sidewarpdmap[0]=(word)tempbyte;
16017
16018
2/6
✓ Branch 0 taken 11016 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11016 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
11016 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16019 {
16020 for(int32_t i=1; i<4; i++)
16021 {
16022 if(!p_getc(&(tempbyte),f,true))
16023 {
16024 return qe_invalid;
16025 }
16026
16027 temp_mapscr->sidewarpdmap[i]=(word)tempbyte;
16028 }
16029 }
16030 else
16031 {
16032 11016 temp_mapscr->sidewarpdmap[1]=0;
16033 11016 temp_mapscr->sidewarpdmap[2]=0;
16034 11016 temp_mapscr->sidewarpdmap[3]=0;
16035 }
16036 11016 }
16037 else
16038 {
16039
2/2
✓ Branch 0 taken 535840 times.
✓ Branch 1 taken 133960 times.
669800 for(int32_t i=0; i<4; i++)
16040 {
16041
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 535840 times.
535840 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f,true))
16042 {
16043 return qe_invalid;
16044 }
16045 535840 }
16046 }
16047
16048
3/6
✓ Branch 0 taken 11016 times.
✓ Branch 1 taken 133960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11016 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16049 {
16050
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(!p_getc(&(temp_mapscr->sidewarpindex),f,true))
16051 {
16052 return qe_invalid;
16053 }
16054 133960 }
16055 11016 else temp_mapscr->sidewarpindex = 0;
16056
16057
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
144976 if(!p_igetw(&(temp_mapscr->undercombo),f,true))
16058 {
16059 return qe_invalid;
16060 }
16061
16062
1/2
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
144976 if(Header->zelda_version < 0x193)
16063 {
16064 if(!p_getc(&(temp_mapscr->old_cpage),f,true))
16065 {
16066 return qe_invalid;
16067 }
16068 }
16069
16070
1/2
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
144976 if(!p_getc(&(temp_mapscr->undercset),f,true)) //recalculated for older quests
16071 {
16072 return qe_invalid;
16073 }
16074
16075
1/2
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
144976 if(!p_igetw(&(temp_mapscr->catchall),f,true))
16076 {
16077 return qe_invalid;
16078 }
16079
16080
1/2
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
144976 if(!p_getc(&(temp_mapscr->flags),f,true))
16081 {
16082 return qe_invalid;
16083 }
16084
16085
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
144976 if(!p_getc(&(temp_mapscr->flags2),f,true))
16086 {
16087 return qe_invalid;
16088 }
16089
16090
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
144976 if(!p_getc(&(temp_mapscr->flags3),f,true))
16091 {
16092 return qe_invalid;
16093 }
16094
16095
3/6
✓ Branch 0 taken 11016 times.
✓ Branch 1 taken 133960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11016 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>1)))
16096 //if (version>2)
16097 {
16098
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(!p_getc(&(temp_mapscr->flags4),f,true))
16099 {
16100 return qe_invalid;
16101 }
16102 133960 }
16103
16104
3/6
✓ Branch 0 taken 11016 times.
✓ Branch 1 taken 133960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11016 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16105 {
16106
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133960 times.
133960 if(!p_getc(&(temp_mapscr->flags5),f,true))
16107 {
16108 return qe_invalid;
16109 }
16110
16111
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(!p_igetw(&(temp_mapscr->noreset),f,true))
16112 {
16113 return qe_invalid;
16114 }
16115
16116
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(!p_igetw(&(temp_mapscr->nocarry),f,true))
16117 {
16118 return qe_invalid;
16119 }
16120
16121
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133960 times.
133960 if(temp_mapscr->flags5&32)
16122 {
16123 temp_mapscr->flags5 &= ~32;
16124 temp_mapscr->noreset |= 48;
16125 }
16126
16127
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133960 times.
133960 if(version<8)
16128 {
16129 if(temp_mapscr->noreset&1)
16130 {
16131 temp_mapscr->noreset|=8192;
16132 }
16133
16134 if(temp_mapscr->nocarry&1)
16135 {
16136 temp_mapscr->nocarry|=8192;
16137 temp_mapscr->nocarry&=~1;
16138 }
16139 }
16140 133960 }
16141 else
16142 {
16143 11016 temp_mapscr->flags5 = 0;
16144 11016 temp_mapscr->noreset = 0;
16145 11016 temp_mapscr->nocarry = 0;
16146 }
16147
16148
3/6
✓ Branch 0 taken 11016 times.
✓ Branch 1 taken 133960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11016 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>9)))
16149 {
16150
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133960 times.
133960 if(!p_getc(&(temp_mapscr->flags6),f,true))
16151 {
16152 return qe_invalid;
16153 }
16154 133960 }
16155
16156
2/2
✓ Branch 0 taken 133960 times.
✓ Branch 1 taken 11016 times.
144976 if(version>5)
16157 {
16158
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(!p_getc(&(temp_mapscr->flags7),f,true))
16159 {
16160 return qe_invalid;
16161 }
16162
16163
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(!p_getc(&(temp_mapscr->flags8),f,true))
16164 {
16165 return qe_invalid;
16166 }
16167
16168
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133960 times.
133960 if(!p_getc(&(temp_mapscr->flags9),f,true))
16169 {
16170 return qe_invalid;
16171 }
16172
16173
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(!p_getc(&(temp_mapscr->flags10),f,true))
16174 {
16175 return qe_invalid;
16176 }
16177
16178
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(!p_getc(&(temp_mapscr->csensitive),f,true))
16179 {
16180 return qe_invalid;
16181 }
16182 133960 }
16183 else
16184 {
16185 11016 temp_mapscr->csensitive=1;
16186 }
16187
16188
2/2
✓ Branch 0 taken 11016 times.
✓ Branch 1 taken 133960 times.
144976 if(version<14) // August 2007: screen SFX added
16189 {
16190
2/2
✓ Branch 0 taken 10962 times.
✓ Branch 1 taken 54 times.
11016 if(temp_mapscr->flags&8) //fROAR
16191 {
16192 54 temp_mapscr->bosssfx=
16193
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 45 times.
54 (temp_mapscr->flags3&2) ? WAV_DODONGO : // fDODONGO
16194 45 (temp_mapscr->flags2&32) ? WAV_VADER : // fVADER
16195 WAV_ROAR;
16196 54 }
16197
16198
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 10941 times.
11016 if(temp_mapscr->flags&128) //fSEA
16199 {
16200 75 temp_mapscr->oceansfx=WAV_SEA;
16201 75 }
16202
16203 11016 temp_mapscr->secretsfx = (temp_mapscr->flags3&64) //fNOSECRETSOUND
16204 ? 0 : WAV_SECRET;
16205
16206 11016 temp_mapscr->flags3 &= ~66; //64|2
16207 11016 temp_mapscr->flags2 &= ~32;
16208 11016 temp_mapscr->flags &= ~136; // 128|8
16209 11016 }
16210 else
16211 {
16212
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133960 times.
133960 if(!p_getc(&(temp_mapscr->oceansfx),f,true))
16213 {
16214 return qe_invalid;
16215 }
16216
16217
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133960 times.
133960 if(!p_getc(&(temp_mapscr->bosssfx),f,true))
16218 {
16219 return qe_invalid;
16220 }
16221
16222
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(!p_getc(&(temp_mapscr->secretsfx),f,true))
16223 {
16224 return qe_invalid;
16225 }
16226 }
16227
16228
2/2
✓ Branch 0 taken 11016 times.
✓ Branch 1 taken 133960 times.
144976 if(version<15) // October 2007: another SFX
16229 {
16230 11016 temp_mapscr->holdupsfx=WAV_PICKUP;
16231 11016 }
16232 else
16233 {
16234
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(!p_getc(&(temp_mapscr->holdupsfx),f,true))
16235 {
16236 return qe_invalid;
16237 }
16238 }
16239
16240
16241
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16242 {
16243
2/2
✓ Branch 0 taken 869856 times.
✓ Branch 1 taken 144976 times.
1014832 for(int32_t k=0; k<6; k++)
16244 {
16245
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 869856 times.
869856 if(!p_getc(&(temp_mapscr->layermap[k]),f,true))
16246 {
16247 return qe_invalid;
16248 }
16249 869856 }
16250
16251
2/2
✓ Branch 0 taken 144976 times.
✓ Branch 1 taken 869856 times.
1014832 for(int32_t k=0; k<6; k++)
16252 {
16253
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 869856 times.
869856 if(!p_getc(&(temp_mapscr->layerscreen[k]),f,true))
16254 {
16255 return qe_invalid;
16256 }
16257 869856 }
16258 144976 }
16259 else if((Header->zelda_version == 0x192)&&(Header->build>23)&&(Header->build<98))
16260 {
16261 if(!p_getc(&(temp_mapscr->layermap[2]),f,true))
16262 {
16263 return qe_invalid;
16264 }
16265
16266 if(!p_getc(&(temp_mapscr->layerscreen[2]),f,true))
16267 {
16268 return qe_invalid;
16269 }
16270
16271 if(!p_getc(&(temp_mapscr->layermap[4]),f,true))
16272 {
16273 return qe_invalid;
16274 }
16275
16276 if(!p_getc(&(temp_mapscr->layerscreen[4]),f,true))
16277
16278 {
16279 return qe_invalid;
16280 }
16281 }
16282
16283
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
144976 if((Header->zelda_version == 0x192)&&(Header->build>149))
16284 {
16285 for(int32_t k=0; k<6; k++)
16286 {
16287 if(!p_getc(&tempbyte,f,true)) //layerxsize
16288 {
16289 return qe_invalid;
16290 }
16291 }
16292
16293 for(int32_t k=0; k<6; k++)
16294 {
16295 if(!p_getc(&tempbyte,f,true)) //layerxspeed
16296 {
16297 return qe_invalid;
16298 }
16299 }
16300
16301 for(int32_t k=0; k<6; k++)
16302 {
16303 if(!p_getc(&tempbyte,f,true)) //layerxdelay
16304 {
16305 return qe_invalid;
16306 }
16307 }
16308
16309 for(int32_t k=0; k<6; k++)
16310 {
16311 if(!p_getc(&tempbyte,f,true)) //layerysize
16312 {
16313 return qe_invalid;
16314 }
16315 }
16316
16317 for(int32_t k=0; k<6; k++)
16318 {
16319 if(!p_getc(&tempbyte,f,true)) //layeryspeed
16320 {
16321 return qe_invalid;
16322 }
16323 }
16324
16325 for(int32_t k=0; k<6; k++)
16326 {
16327 if(!p_getc(&tempbyte,f,true)) //layerydelay
16328 {
16329 return qe_invalid;
16330 }
16331 }
16332 }
16333
16334
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>149)))
16335 {
16336
2/2
✓ Branch 0 taken 869856 times.
✓ Branch 1 taken 144976 times.
1014832 for(int32_t k=0; k<6; k++)
16337 {
16338
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 869856 times.
869856 if(!p_getc(&(temp_mapscr->layeropacity[k]),f,true))
16339 {
16340 return qe_invalid;
16341 }
16342 869856 }
16343 144976 }
16344
16345
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16346 {
16347
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
144976 if((Header->zelda_version == 0x192)&&(Header->build>153))
16348 {
16349 if(!p_getc(&padding,f,true))
16350 {
16351 return qe_invalid;
16352 }
16353 }
16354
16355
1/2
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
144976 if(!p_igetw(&(temp_mapscr->timedwarptics),f,true))
16356 {
16357 return qe_invalid;
16358 }
16359 144976 }
16360
16361
2/6
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 144976 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<24)))
16362 {
16363 extras=15;
16364 }
16365
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
144976 else if(((Header->zelda_version == 0x192)&&(Header->build<98)))
16366 {
16367 extras=11;
16368 }
16369
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
144976 else if((Header->zelda_version == 0x192)&&(Header->build<150))
16370 {
16371 extras=32;
16372 }
16373
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
144976 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16374 {
16375 extras=64;
16376 }
16377
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
144976 else if(Header->zelda_version < 0x193)
16378 {
16379 extras=62;
16380 }
16381 else
16382
16383 {
16384 144976 extras=0;
16385 }
16386
16387
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
144976 for(int32_t k=0; k<extras; k++)
16388 {
16389 if(!p_getc(&tempbyte,f,true)) //extra[k]
16390 {
16391 return qe_invalid;
16392 }
16393 }
16394
16395
3/6
✓ Branch 0 taken 11016 times.
✓ Branch 1 taken 133960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11016 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>2)))
16396 //if (version>3)
16397 {
16398
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133960 times.
133960 if(!p_getc(&(temp_mapscr->nextmap),f,true))
16399 {
16400 return qe_invalid;
16401 }
16402
16403
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(!p_getc(&(temp_mapscr->nextscr),f,true))
16404 {
16405 return qe_invalid;
16406 }
16407 133960 }
16408 else
16409 {
16410 11016 temp_mapscr->nextmap=0;
16411 11016 temp_mapscr->nextscr=0;
16412 }
16413
16414
2/6
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 144976 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16415 {
16416 secretcombos=20;
16417 }
16418
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
144976 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16419 {
16420 secretcombos=256;
16421 }
16422 else
16423 {
16424 144976 secretcombos=128;
16425 }
16426
16427
2/6
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 144976 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16428 {
16429 for(int32_t k=0; k<secretcombos; k++)
16430 {
16431 if(!p_getc(&tempbyte,f,true))
16432 {
16433 return qe_invalid;
16434 }
16435
16436 if(k<128)
16437 {
16438 temp_mapscr->secretcombo[k]=tempbyte;
16439 }
16440 }
16441 }
16442 else
16443 {
16444
2/2
✓ Branch 0 taken 18556928 times.
✓ Branch 1 taken 144976 times.
18701904 for(int32_t k=0; k<128; k++)
16445 {
16446
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18556928 times.
18556928 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f,true))
16447 {
16448 return qe_invalid;
16449 }
16450
16451 18556928 }
16452 }
16453
16454
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16455 {
16456
2/2
✓ Branch 0 taken 18556928 times.
✓ Branch 1 taken 144976 times.
18701904 for(int32_t k=0; k<128; k++)
16457 {
16458
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18556928 times.
18556928 if(!p_getc(&(temp_mapscr->secretcset[k]),f,true))
16459 {
16460 return qe_invalid;
16461 }
16462 18556928 }
16463
16464
2/2
✓ Branch 0 taken 18556928 times.
✓ Branch 1 taken 144976 times.
18701904 for(int32_t k=0; k<128; k++)
16465 {
16466
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18556928 times.
18556928 if(!p_getc(&(temp_mapscr->secretflag[k]),f,true))
16467 {
16468 return qe_invalid;
16469 }
16470 18556928 }
16471 144976 }
16472
16473
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version == 0x192)&&(Header->build>97)&&(Header->build<154))
16474 {
16475 if(!p_getc(&padding,f,true))
16476 {
16477 return qe_invalid;
16478 }
16479 }
16480
16481 144976 const int32_t _mapsSize = (temp_map->tileWidth*temp_map->tileHeight);
16482
16483
2/2
✓ Branch 0 taken 25515776 times.
✓ Branch 1 taken 144976 times.
25660752 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16484 {
16485
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25515776 times.
25515776 if(!p_igetw(&(temp_mapscr->data[k]),f,true))
16486 {
16487 return qe_invalid;
16488 }
16489 25515776 }
16490
16491
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version == 0x192)&&(Header->build>20)&&(Header->build<24))
16492 {
16493 if(!p_getc(&padding,f,true))
16494 {
16495 return qe_invalid;
16496 }
16497
16498 if(!p_getc(&padding,f,true))
16499 {
16500 return qe_invalid;
16501 }
16502 }
16503
16504
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>20)))
16505 {
16506
2/2
✓ Branch 0 taken 25515776 times.
✓ Branch 1 taken 144976 times.
25660752 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16507 {
16508
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25515776 times.
25515776 if(!p_getc(&(temp_mapscr->sflag[k]),f,true))
16509 {
16510 return qe_invalid;
16511 }
16512
16513
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 25515776 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
25515776 if((Header->zelda_version == 0x192)&&(Header->build<24))
16514 {
16515 if(!p_getc(&tempbyte,f,true))
16516 {
16517 return qe_invalid;
16518 }
16519
16520 if(!p_getc(&tempbyte,f,true))
16521 {
16522 return qe_invalid;
16523 }
16524
16525 if(!p_getc(&tempbyte,f,true))
16526 {
16527 return qe_invalid;
16528 }
16529 }
16530 25515776 }
16531 144976 }
16532
16533
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16534 {
16535
2/2
✓ Branch 0 taken 144976 times.
✓ Branch 1 taken 25515776 times.
25660752 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16536 {
16537
16538
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25515776 times.
25515776 if(!p_getc(&(temp_mapscr->cset[k]),f,true))
16539 {
16540 return qe_invalid;
16541 }
16542 25515776 }
16543 144976 }
16544
16545
2/6
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 144976 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16546 {
16547 temp_mapscr->undercset=(temp_mapscr->undercombo>>8)&7;
16548 temp_mapscr->undercombo=(temp_mapscr->undercombo&0xFF)+(temp_mapscr->old_cpage<<8);
16549 }
16550
16551
2/6
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 144976 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16552 {
16553 temp_mapscr->secretcombo[sSBOMB]=temp_mapscr->secretcombo[sBOMB];
16554 temp_mapscr->secretcombo[sRCANDLE]=temp_mapscr->secretcombo[sBCANDLE];
16555 temp_mapscr->secretcombo[sWANDFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16556 temp_mapscr->secretcombo[sDINSFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16557 temp_mapscr->secretcombo[sSARROW]=temp_mapscr->secretcombo[sARROW];
16558 temp_mapscr->secretcombo[sGARROW]=temp_mapscr->secretcombo[sARROW];
16559 }
16560
16561
2/6
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 144976 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16562 {
16563 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16564 {
16565 if((Header->zelda_version == 0x192)&&(Header->build>149))
16566 {
16567 if((Header->zelda_version == 0x192)&&(Header->build!=153))
16568 {
16569 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16570 }
16571 }
16572 else
16573 {
16574 if((Header->zelda_version < 0x192)||
16575 ((Header->zelda_version == 0x192)&&(Header->build<21)))
16576 {
16577 temp_mapscr->sflag[k]=(temp_mapscr->data[k]>>11);
16578 }
16579
16580 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16581 }
16582
16583 temp_mapscr->data[k]=(temp_mapscr->data[k]&0xFF)+(temp_mapscr->old_cpage<<8);
16584 }
16585 }
16586
16587 /*if(version>12)
16588 {
16589 if(!p_getc(&(temp_mapscr->scrWidth),f,true))
16590 {
16591 return qe_invalid;
16592 }
16593 if(!p_getc(&(temp_mapscr->scrHeight),f,true))
16594 {
16595 return qe_invalid;
16596 }
16597 }*/
16598
16599
2/2
✓ Branch 0 taken 133960 times.
✓ Branch 1 taken 11016 times.
144976 if(version>4)
16600 {
16601
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(!p_igetw(&(temp_mapscr->screen_midi),f,true))
16602 {
16603 return qe_invalid;
16604 }
16605 133960 }
16606 else
16607 {
16608 11016 temp_mapscr->screen_midi = -1;
16609 }
16610
16611
2/2
✓ Branch 0 taken 133960 times.
✓ Branch 1 taken 11016 times.
144976 if(version>=17)
16612 {
16613
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(!p_getc(&(temp_mapscr->lens_layer),f,true))
16614 {
16615 return qe_invalid;
16616 }
16617 133960 }
16618 else
16619 {
16620 11016 temp_mapscr->lens_layer = llNORMAL;
16621 }
16622
16623
2/2
✓ Branch 0 taken 11016 times.
✓ Branch 1 taken 133960 times.
144976 if(version>6)
16624 {
16625 dword bits;
16626
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133960 times.
133960 if(!p_igetl(&bits,f,true))
16627 {
16628 return qe_invalid;
16629 }
16630
16631 int32_t m;
16632 float tempfloat;
16633 word tempw;
16634 133960 temp_mapscr->ffcCountMarkDirty();
16635
16636
2/2
✓ Branch 0 taken 133960 times.
✓ Branch 1 taken 4286720 times.
4420680 for(m=0; m<32; m++)
16637 {
16638 4286720 ffcdata& tempffc = temp_mapscr->ffcs[m];
16639 4286720 tempffc.clear();
16640
2/2
✓ Branch 0 taken 4275651 times.
✓ Branch 1 taken 11069 times.
4286720 if((bits>>m)&1)
16641 {
16642
1/2
✓ Branch 0 taken 11069 times.
✗ Branch 1 not taken.
11069 if(!p_igetw(&tempw,f,true))
16643 {
16644 return qe_invalid;
16645 }
16646 11069 tempffc.setData(tempw);
16647
16648
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_getc(&(tempffc.cset),f,true))
16649 {
16650 return qe_invalid;
16651 }
16652
16653
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_igetw(&(tempffc.delay),f,true))
16654 {
16655 return qe_invalid;
16656 }
16657
16658
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(version < 9)
16659 {
16660 if(!p_igetf(&tempfloat,f,true))
16661 {
16662 return qe_invalid;
16663 }
16664
16665 tempffc.x=zslongToFix(int32_t(tempfloat*10000));
16666
16667 if(!p_igetf(&tempfloat,f,true))
16668 {
16669 return qe_invalid;
16670 }
16671
16672 tempffc.y=zslongToFix(int32_t(tempfloat*10000));
16673
16674 if(!p_igetf(&tempfloat,f,true))
16675 {
16676 return qe_invalid;
16677 }
16678
16679 tempffc.vx=zslongToFix(int32_t(tempfloat*10000));
16680
16681 if(!p_igetf(&tempfloat,f,true))
16682 {
16683 return qe_invalid;
16684 }
16685
16686 tempffc.vy=zslongToFix(int32_t(tempfloat*10000));
16687
16688 if(!p_igetf(&tempfloat,f,true))
16689 {
16690 return qe_invalid;
16691 }
16692
16693 tempffc.ax=zslongToFix(int32_t(tempfloat*10000));
16694
16695 if(!p_igetf(&tempfloat,f,true))
16696 {
16697 return qe_invalid;
16698 }
16699
16700 tempffc.ay=zslongToFix(int32_t(tempfloat*10000));
16701 }
16702 else
16703 {
16704
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_igetzf(&(tempffc.x),f,true))
16705 {
16706 return qe_invalid;
16707 }
16708
16709
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_igetzf(&(tempffc.y),f,true))
16710 {
16711 return qe_invalid;
16712 }
16713
16714
1/2
✓ Branch 0 taken 11069 times.
✗ Branch 1 not taken.
11069 if(!p_igetzf(&(tempffc.vx),f,true))
16715 {
16716 return qe_invalid;
16717 }
16718
16719
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_igetzf(&(tempffc.vy),f,true))
16720 {
16721 return qe_invalid;
16722 }
16723
16724
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_igetzf(&(tempffc.ax),f,true))
16725 {
16726 return qe_invalid;
16727 }
16728
16729
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_igetzf(&(tempffc.ay),f,true))
16730 {
16731 return qe_invalid;
16732 }
16733 }
16734
16735
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_getc(&(tempffc.link),f,true))
16736 {
16737 return qe_invalid;
16738 }
16739
16740
1/2
✓ Branch 0 taken 11069 times.
✗ Branch 1 not taken.
11069 if(version>7)
16741 {
16742
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_getc(&tempbyte,f,true))
16743 {
16744 return qe_invalid;
16745 }
16746
16747 11069 tempffc.hxsz = (tempbyte&0x3F)+1;
16748 11069 tempffc.txsz = (tempbyte>>6)+1;
16749
16750
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_getc(&tempbyte,f,true))
16751 {
16752 return qe_invalid;
16753 }
16754
16755 11069 tempffc.hysz = (tempbyte&0x3F)+1;
16756 11069 tempffc.tysz = (tempbyte>>6)+1;
16757
16758
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_igetl(&(tempffc.flags),f,true))
16759 {
16760 return qe_invalid;
16761 }
16762 11069 }
16763 else
16764 {
16765 tempffc.hxsz=16;
16766 tempffc.hysz=16;
16767 tempffc.txsz=1;
16768 tempffc.tysz=1;
16769 tempffc.flags=0;
16770 }
16771
16772 11069 tempffc.updateSolid();
16773
16774
16775
4/6
✓ Branch 0 taken 11069 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9049 times.
✓ Branch 3 taken 2020 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 9049 times.
11069 if(Header->zelda_version == 0x211 || (Header->zelda_version == 0x250 && Header->build<20))
16776 {
16777 tempffc.flags|=ffIGNOREHOLDUP;
16778 }
16779
16780
1/2
✓ Branch 0 taken 11069 times.
✗ Branch 1 not taken.
11069 if(version>9)
16781 {
16782
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_igetw(&(tempffc.script),f,true))
16783 {
16784 return qe_invalid;
16785 }
16786 11069 }
16787 else
16788 {
16789 tempffc.script=0;
16790 }
16791
16792
1/2
✓ Branch 0 taken 11069 times.
✗ Branch 1 not taken.
11069 if(version>10)
16793 {
16794
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_igetl(&(tempffc.initd[0]),f,true))
16795 {
16796 return qe_invalid;
16797 }
16798
16799
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_igetl(&(tempffc.initd[1]),f,true))
16800 {
16801 return qe_invalid;
16802 }
16803
16804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_igetl(&(tempffc.initd[2]),f,true))
16805 {
16806 return qe_invalid;
16807 }
16808
16809
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_igetl(&(tempffc.initd[3]),f,true))
16810 {
16811 return qe_invalid;
16812 }
16813
16814
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_igetl(&(tempffc.initd[4]),f,true))
16815 {
16816 return qe_invalid;
16817 }
16818
16819
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_igetl(&(tempffc.initd[5]),f,true))
16820 {
16821 return qe_invalid;
16822 }
16823
16824
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_igetl(&(tempffc.initd[6]),f,true))
16825 {
16826 return qe_invalid;
16827 }
16828
16829
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_igetl(&(tempffc.initd[7]),f,true))
16830 {
16831 return qe_invalid;
16832 }
16833
16834
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_getc(&(tempbyte),f,true))
16835 {
16836 return qe_invalid;
16837 }
16838
16839 11069 tempffc.inita[0]=tempbyte*10000;
16840
16841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_getc(&(tempbyte),f,true))
16842 {
16843 return qe_invalid;
16844 }
16845
16846 11069 tempffc.inita[1]=tempbyte*10000;
16847 11069 }
16848 else
16849 {
16850 tempffc.inita[0] = 10000;
16851 tempffc.inita[1] = 10000;
16852 }
16853
16854 11069 tempffc.initialized = false;
16855
16856
1/2
✓ Branch 0 taken 11069 times.
✗ Branch 1 not taken.
11069 if(version <= 11)
16857 {
16858 fixffcs=true;
16859 }
16860 11069 }
16861 4286720 }
16862
16863 133960 }
16864
16865 //add in the new whistle flags
16866
2/2
✓ Branch 0 taken 133960 times.
✓ Branch 1 taken 11016 times.
144976 if(version<13)
16867 {
16868
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11016 times.
11016 if(temp_mapscr->flags & fWHISTLE)
16869 {
16870 temp_mapscr->flags7 |= (fWHISTLEPAL | fWHISTLEWATER);
16871 }
16872 11016 }
16873
16874 // for(int32_t m=0; m<32; m++)
16875 // {
16876 // // ffcScriptData used to be part of mapscr, and this was handled just above
16877 // ffcScriptData[m].a[0] = 10000;
16878 // ffcScriptData[m].a[1] = 10000;
16879 // }
16880
16881 //2.55 starts here
16882
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 131240 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
144976 if ( version >= 19 && Header->zelda_version > 0x253 )
16883 {
16884
2/2
✓ Branch 0 taken 137360 times.
✓ Branch 1 taken 13736 times.
151096 for ( int32_t q = 0; q < 10; q++ )
16885 {
16886
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetl(&(temp_mapscr->npcstrings[q]),f,true))
16887 {
16888 return qe_invalid;
16889 }
16890 137360 }
16891
2/2
✓ Branch 0 taken 137360 times.
✓ Branch 1 taken 13736 times.
151096 for ( int32_t q = 0; q < 10; q++ )
16892 {
16893
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetw(&(temp_mapscr->new_items[q]),f,true))
16894 {
16895 return qe_invalid;
16896 }
16897 137360 }
16898
2/2
✓ Branch 0 taken 137360 times.
✓ Branch 1 taken 13736 times.
151096 for ( int32_t q = 0; q < 10; q++ )
16899 {
16900
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetw(&(temp_mapscr->new_item_x[q]),f,true))
16901 {
16902 return qe_invalid;
16903 }
16904 137360 }
16905
2/2
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 137360 times.
151096 for ( int32_t q = 0; q < 10; q++ )
16906 {
16907
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetw(&(temp_mapscr->new_item_y[q]),f,true))
16908 {
16909 return qe_invalid;
16910 }
16911 137360 }
16912 13736 }
16913
3/4
✓ Branch 0 taken 131240 times.
✓ Branch 1 taken 13736 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 131240 times.
144976 if ( version < 19 && Header->zelda_version > 0x253 )
16914 {
16915 for ( int32_t q = 0; q < 10; q++ )
16916 {
16917 temp_mapscr->npcstrings[q] = 0;
16918 temp_mapscr->new_items[q] = 0;
16919 temp_mapscr->new_item_x[q] = 0;
16920 temp_mapscr->new_item_y[q] = 0;
16921 }
16922 }
16923
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 131240 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
144976 if ( version >= 20 && Header->zelda_version > 0x253 )
16924 {
16925
1/2
✓ Branch 0 taken 13736 times.
✗ Branch 1 not taken.
13736 if(!p_igetw(&(temp_mapscr->script),f,true))
16926 {
16927 return qe_invalid;
16928 }
16929
2/2
✓ Branch 0 taken 109888 times.
✓ Branch 1 taken 13736 times.
123624 for ( int32_t q = 0; q < 8; q++)
16930 {
16931
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109888 times.
109888 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f,true))
16932 {
16933 return qe_invalid;
16934 }
16935 109888 }
16936 13736 }
16937
2/2
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 131240 times.
144976 if ( version < 20 )
16938 {
16939 131240 temp_mapscr->script = 0;
16940
2/2
✓ Branch 0 taken 1049920 times.
✓ Branch 1 taken 131240 times.
1181160 for ( int32_t q = 0; q < 8; q++) temp_mapscr->screeninitd[q] = 0;
16941 131240 }
16942
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 131240 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
144976 if ( version >= 21 && Header->zelda_version > 0x253 )
16943 {
16944
1/2
✓ Branch 0 taken 13736 times.
✗ Branch 1 not taken.
13736 if(!p_getc(&(temp_mapscr->preloadscript),f,true))
16945 {
16946 return qe_invalid;
16947 }
16948 13736 }
16949
2/2
✓ Branch 0 taken 131240 times.
✓ Branch 1 taken 13736 times.
144976 if ( version < 21 )
16950 {
16951 131240 temp_mapscr->preloadscript = 0;
16952 131240 }
16953 //all builds with version > 20 need this. -Z
16954 144976 temp_mapscr->ffcswaitdraw = 0;
16955
16956
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 131240 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
144976 if ( version >= 22 && Header->zelda_version > 0x253 ) //26th June, 2019; Layer Visibility
16957 {
16958
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13736 times.
13736 if(!p_getc(&(temp_mapscr->hidelayers ),f,true))
16959 {
16960 return qe_invalid;
16961 }
16962
1/2
✓ Branch 0 taken 13736 times.
✗ Branch 1 not taken.
13736 if(!p_getc(&(temp_mapscr->hidescriptlayers ),f,true))
16963 {
16964 return qe_invalid;
16965 }
16966 13736 }
16967
2/2
✓ Branch 0 taken 131240 times.
✓ Branch 1 taken 13736 times.
144976 if ( version < 22 )
16968 {
16969 131240 temp_mapscr->hidelayers = 0;
16970 131240 temp_mapscr->hidescriptlayers = 0;
16971 131240 }
16972
16973 //Dodongos in 2.10 used the boss roar, not the dodongo sound. -Z
16974 //May be any version before 2.11. -Z
16975 /* --not the roar, the HIT SFX
16976 if ( Header->zelda_version <= 0x210 )
16977 {
16978 if ( temp_mapscr->bosssfx == WAV_DODONGO )
16979 {
16980 temp_mapscr->bosssfx = WAV_ROAR;
16981 }
16982 }
16983 */
16984
16985 144976 return 0;
16986 144976 }
16987 157216 int32_t readmapscreen(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, zcmap *temp_map, word version)
16988 {
16989
2/2
✓ Branch 0 taken 144976 times.
✓ Branch 1 taken 12240 times.
157216 if(version < 23)
16990 {
16991 144976 auto ret = readmapscreen_old(f,Header,temp_mapscr,temp_map,version);
16992
1/2
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
144976 if(ret) return ret;
16993 144976 }
16994 else
16995 {
16996
1/2
✓ Branch 0 taken 12240 times.
✗ Branch 1 not taken.
12240 if(!p_getc(&(temp_mapscr->valid),f,true))
16997 return qe_invalid;
16998
2/2
✓ Branch 0 taken 5234 times.
✓ Branch 1 taken 7006 times.
12240 if(!(temp_mapscr->valid & mVALID))
16999 7006 return 0; //Empty screen
17000 uint32_t scr_has_flags;
17001
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5234 times.
5234 if(!p_igetl(&scr_has_flags,f,true))
17002 return qe_invalid;
17003
17004
2/2
✓ Branch 0 taken 5189 times.
✓ Branch 1 taken 45 times.
5234 if(scr_has_flags & SCRHAS_ROOMDATA)
17005 {
17006
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 if(!p_getc(&(temp_mapscr->guy),f,true))
17007 return qe_invalid;
17008
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 if(!p_igetw(&(temp_mapscr->str),f,true))
17009 return qe_invalid;
17010
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
45 if(!p_getc(&(temp_mapscr->room),f,true))
17011 return qe_invalid;
17012
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 if(!p_igetw(&(temp_mapscr->catchall),f,true))
17013 return qe_invalid;
17014 45 }
17015
2/2
✓ Branch 0 taken 5153 times.
✓ Branch 1 taken 81 times.
5234 if(scr_has_flags & SCRHAS_ITEM)
17016 {
17017
1/2
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
81 if(!p_getc(&(temp_mapscr->item),f,true))
17018 return qe_invalid;
17019
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81 times.
81 if(!p_getc(&(temp_mapscr->hasitem),f,true))
17020 return qe_invalid;
17021
1/2
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
81 if(!p_getc(&(temp_mapscr->itemx),f,true))
17022 return qe_invalid;
17023
1/2
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
81 if(!p_getc(&(temp_mapscr->itemy),f,true))
17024 return qe_invalid;
17025 81 }
17026
2/2
✓ Branch 0 taken 4942 times.
✓ Branch 1 taken 292 times.
5234 if(scr_has_flags & (SCRHAS_SWARP|SCRHAS_TWARP))
17027 {
17028
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 if(!p_igetw(&temp_mapscr->warpreturnc,f,true))
17029 return qe_invalid;
17030 292 }
17031
2/2
✓ Branch 0 taken 5036 times.
✓ Branch 1 taken 198 times.
5234 if(scr_has_flags & SCRHAS_TWARP)
17032 {
17033
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t i=0; i<4; i++)
17034 {
17035
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f,true))
17036 return qe_invalid;
17037 792 }
17038
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t i=0; i<4; i++)
17039 {
17040
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f,true))
17041 return qe_invalid;
17042 792 }
17043
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t i=0; i<4; i++)
17044 {
17045
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f,true))
17046 return qe_invalid;
17047 792 }
17048
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f,true))
17049 return qe_invalid;
17050 198 }
17051
2/2
✓ Branch 0 taken 5116 times.
✓ Branch 1 taken 118 times.
5234 if(scr_has_flags & SCRHAS_SWARP)
17052 {
17053
2/2
✓ Branch 0 taken 472 times.
✓ Branch 1 taken 118 times.
590 for(int32_t i=0; i<4; i++)
17054 {
17055
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 472 times.
472 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f,true))
17056 return qe_invalid;
17057 472 }
17058
2/2
✓ Branch 0 taken 472 times.
✓ Branch 1 taken 118 times.
590 for(int32_t i=0; i<4; i++)
17059 {
17060
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 472 times.
472 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f,true))
17061 return qe_invalid;
17062 472 }
17063
2/2
✓ Branch 0 taken 472 times.
✓ Branch 1 taken 118 times.
590 for(int32_t i=0; i<4; i++)
17064 {
17065
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 472 times.
472 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f,true))
17066 return qe_invalid;
17067 472 }
17068
1/2
✓ Branch 0 taken 118 times.
✗ Branch 1 not taken.
118 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f,true))
17069 return qe_invalid;
17070
1/2
✓ Branch 0 taken 118 times.
✗ Branch 1 not taken.
118 if(!p_getc(&(temp_mapscr->sidewarpindex),f,true))
17071 return qe_invalid;
17072 118 }
17073
2/2
✓ Branch 0 taken 4938 times.
✓ Branch 1 taken 296 times.
5234 if(scr_has_flags & SCRHAS_WARPRET)
17074 {
17075
2/2
✓ Branch 0 taken 1184 times.
✓ Branch 1 taken 296 times.
1480 for(int32_t i=0; i<4; i++)
17076 {
17077
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1184 times.
1184 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f,true))
17078 return qe_invalid;
17079 1184 }
17080
2/2
✓ Branch 0 taken 1184 times.
✓ Branch 1 taken 296 times.
1480 for(int32_t i=0; i<4; i++)
17081 {
17082
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1184 times.
1184 if(!p_getc(&(temp_mapscr->warpreturny[i]),f,true))
17083 return qe_invalid;
17084 1184 }
17085
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&(temp_mapscr->warparrivalx),f,true))
17086 return qe_invalid;
17087
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&(temp_mapscr->warparrivaly),f,true))
17088 return qe_invalid;
17089 296 }
17090
2/2
✓ Branch 0 taken 1030 times.
✓ Branch 1 taken 4204 times.
5234 if(scr_has_flags & SCRHAS_LAYERS)
17091 {
17092
2/2
✓ Branch 0 taken 6180 times.
✓ Branch 1 taken 1030 times.
7210 for(int32_t k=0; k<6; k++)
17093 {
17094
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6180 times.
6180 if(!p_getc(&(temp_mapscr->layermap[k]),f,true))
17095 return qe_invalid;
17096 6180 }
17097
2/2
✓ Branch 0 taken 6180 times.
✓ Branch 1 taken 1030 times.
7210 for(int32_t k=0; k<6; k++)
17098 {
17099
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6180 times.
6180 if(!p_getc(&(temp_mapscr->layerscreen[k]),f,true))
17100 return qe_invalid;
17101 6180 }
17102
2/2
✓ Branch 0 taken 6180 times.
✓ Branch 1 taken 1030 times.
7210 for(int32_t k=0; k<6; k++)
17103 {
17104
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6180 times.
6180 if(!p_getc(&(temp_mapscr->layeropacity[k]),f,true))
17105 return qe_invalid;
17106 6180 }
17107
1/2
✓ Branch 0 taken 1030 times.
✗ Branch 1 not taken.
1030 if(!p_getc(&(temp_mapscr->hidelayers),f,true))
17108 return qe_invalid;
17109
1/2
✓ Branch 0 taken 1030 times.
✗ Branch 1 not taken.
1030 if(!p_getc(&(temp_mapscr->hidescriptlayers),f,true))
17110 return qe_invalid;
17111 1030 }
17112 else
17113 {
17114
2/2
✓ Branch 0 taken 25224 times.
✓ Branch 1 taken 4204 times.
29428 for(int32_t k=0; k<6; k++)
17115 {
17116 25224 temp_mapscr->layeropacity[k] = 255;
17117 25224 }
17118 }
17119
1/2
✓ Branch 0 taken 5234 times.
✗ Branch 1 not taken.
5234 if(scr_has_flags & SCRHAS_MAZE)
17120 {
17121 for(int32_t k=0; k<4; k++)
17122 {
17123 if(!p_getc(&(temp_mapscr->path[k]),f,true))
17124 return qe_invalid;
17125 }
17126 if(!p_getc(&(temp_mapscr->exitdir),f,true))
17127 return qe_invalid;
17128 }
17129
2/2
✓ Branch 0 taken 5138 times.
✓ Branch 1 taken 96 times.
5234 if(scr_has_flags & SCRHAS_D_S_U)
17130 {
17131
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetw(&(temp_mapscr->door_combo_set),f,true))
17132 return qe_invalid;
17133
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 96 times.
480 for(int32_t k=0; k<4; k++)
17134 {
17135
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if(!p_getc(&(temp_mapscr->door[k]),f,true))
17136 return qe_invalid;
17137 384 }
17138
17139
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&(temp_mapscr->stairx),f,true))
17140 return qe_invalid;
17141
17142
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&(temp_mapscr->stairy),f,true))
17143 return qe_invalid;
17144
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_igetw(&(temp_mapscr->undercombo),f,true))
17145 return qe_invalid;
17146
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&(temp_mapscr->undercset),f,true))
17147 return qe_invalid;
17148 96 }
17149
2/2
✓ Branch 0 taken 4877 times.
✓ Branch 1 taken 357 times.
5234 if(scr_has_flags & SCRHAS_FLAGS)
17150 {
17151
1/2
✓ Branch 0 taken 357 times.
✗ Branch 1 not taken.
357 if(!p_getc(&(temp_mapscr->flags),f,true))
17152 return qe_invalid;
17153
1/2
✓ Branch 0 taken 357 times.
✗ Branch 1 not taken.
357 if(!p_getc(&(temp_mapscr->flags2),f,true))
17154 return qe_invalid;
17155
1/2
✓ Branch 0 taken 357 times.
✗ Branch 1 not taken.
357 if(!p_getc(&(temp_mapscr->flags3),f,true))
17156 return qe_invalid;
17157
1/2
✓ Branch 0 taken 357 times.
✗ Branch 1 not taken.
357 if(!p_getc(&(temp_mapscr->flags4),f,true))
17158 return qe_invalid;
17159
1/2
✓ Branch 0 taken 357 times.
✗ Branch 1 not taken.
357 if(!p_getc(&(temp_mapscr->flags5),f,true))
17160 return qe_invalid;
17161
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 357 times.
357 if(!p_getc(&(temp_mapscr->flags6),f,true))
17162 return qe_invalid;
17163
1/2
✓ Branch 0 taken 357 times.
✗ Branch 1 not taken.
357 if(!p_getc(&(temp_mapscr->flags7),f,true))
17164 return qe_invalid;
17165
1/2
✓ Branch 0 taken 357 times.
✗ Branch 1 not taken.
357 if(!p_getc(&(temp_mapscr->flags8),f,true))
17166 return qe_invalid;
17167
1/2
✓ Branch 0 taken 357 times.
✗ Branch 1 not taken.
357 if(!p_getc(&(temp_mapscr->flags9),f,true))
17168 return qe_invalid;
17169
1/2
✓ Branch 0 taken 357 times.
✗ Branch 1 not taken.
357 if(!p_getc(&(temp_mapscr->flags10),f,true))
17170 return qe_invalid;
17171
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 357 times.
357 if(!p_getc(&(temp_mapscr->enemyflags),f,true))
17172 return qe_invalid;
17173 357 }
17174
2/2
✓ Branch 0 taken 4916 times.
✓ Branch 1 taken 318 times.
5234 if(scr_has_flags & SCRHAS_ENEMY)
17175 {
17176
2/2
✓ Branch 0 taken 3180 times.
✓ Branch 1 taken 318 times.
3498 for(int32_t k=0; k<10; k++)
17177 {
17178
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3180 times.
3180 if(!p_igetw(&(temp_mapscr->enemy[k]),f,true))
17179 return qe_invalid;
17180
1/2
✓ Branch 0 taken 3180 times.
✗ Branch 1 not taken.
3180 if (unsigned(temp_mapscr->enemy[k]) > MAXGUYS)
17181 temp_mapscr->enemy[k] = 0;
17182 3180 }
17183
1/2
✓ Branch 0 taken 318 times.
✗ Branch 1 not taken.
318 if(!p_getc(&(temp_mapscr->pattern),f,true))
17184 return qe_invalid;
17185 318 }
17186
2/2
✓ Branch 0 taken 5203 times.
✓ Branch 1 taken 31 times.
5234 if(scr_has_flags & SCRHAS_CARRY)
17187 {
17188
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(!p_igetw(&(temp_mapscr->noreset),f,true))
17189 return qe_invalid;
17190
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(!p_igetw(&(temp_mapscr->nocarry),f,true))
17191 return qe_invalid;
17192
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(!p_getc(&(temp_mapscr->nextmap),f,true))
17193 return qe_invalid;
17194
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(!p_getc(&(temp_mapscr->nextscr),f,true))
17195 return qe_invalid;
17196 31 }
17197
2/2
✓ Branch 0 taken 5210 times.
✓ Branch 1 taken 24 times.
5234 if(scr_has_flags & SCRHAS_SCRIPT)
17198 {
17199
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_igetw(&(temp_mapscr->script),f,true))
17200 return qe_invalid;
17201
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&(temp_mapscr->preloadscript),f,true))
17202 return qe_invalid;
17203
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 24 times.
216 for ( int32_t q = 0; q < 8; q++ )
17204 {
17205
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f,true))
17206 return qe_invalid;
17207 192 }
17208 24 }
17209
1/2
✓ Branch 0 taken 5234 times.
✗ Branch 1 not taken.
5234 if(scr_has_flags & SCRHAS_UNUSED)
17210 {
17211 for ( int32_t q = 0; q < 10; q++ )
17212 {
17213 if(!p_igetl(&(temp_mapscr->npcstrings[q]),f,true))
17214 return qe_invalid;
17215 }
17216 for ( int32_t q = 0; q < 10; q++ )
17217 {
17218 if(!p_igetw(&(temp_mapscr->new_items[q]),f,true))
17219 return qe_invalid;
17220 }
17221 for ( int32_t q = 0; q < 10; q++ )
17222 {
17223 if(!p_igetw(&(temp_mapscr->new_item_x[q]),f,true))
17224 return qe_invalid;
17225 }
17226 for ( int32_t q = 0; q < 10; q++ )
17227 {
17228 if(!p_igetw(&(temp_mapscr->new_item_y[q]),f,true))
17229 return qe_invalid;
17230 }
17231 }
17232
2/2
✓ Branch 0 taken 4889 times.
✓ Branch 1 taken 345 times.
5234 if(scr_has_flags & SCRHAS_SECRETS)
17233 {
17234
2/2
✓ Branch 0 taken 44160 times.
✓ Branch 1 taken 345 times.
44505 for(int32_t k=0; k<128; k++)
17235 {
17236
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44160 times.
44160 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f,true))
17237 return qe_invalid;
17238 44160 }
17239
2/2
✓ Branch 0 taken 44160 times.
✓ Branch 1 taken 345 times.
44505 for(int32_t k=0; k<128; k++)
17240 {
17241
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44160 times.
44160 if(!p_getc(&(temp_mapscr->secretcset[k]),f,true))
17242 return qe_invalid;
17243 44160 }
17244
2/2
✓ Branch 0 taken 44160 times.
✓ Branch 1 taken 345 times.
44505 for(int32_t k=0; k<128; k++)
17245 {
17246
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44160 times.
44160 if(!p_getc(&(temp_mapscr->secretflag[k]),f,true))
17247 return qe_invalid;
17248 44160 }
17249 345 }
17250
2/2
✓ Branch 0 taken 2859 times.
✓ Branch 1 taken 2375 times.
5234 if(scr_has_flags & SCRHAS_COMBOFLAG)
17251 {
17252
2/2
✓ Branch 0 taken 418000 times.
✓ Branch 1 taken 2375 times.
420375 for(int32_t k=0; k<176; ++k)
17253 {
17254
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 418000 times.
418000 if(!p_igetw(&(temp_mapscr->data[k]),f,true))
17255 return qe_invalid;
17256 418000 }
17257
2/2
✓ Branch 0 taken 418000 times.
✓ Branch 1 taken 2375 times.
420375 for(int32_t k=0; k<176; ++k)
17258 {
17259
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 418000 times.
418000 if(!p_getc(&(temp_mapscr->sflag[k]),f,true))
17260 return qe_invalid;
17261 418000 }
17262
2/2
✓ Branch 0 taken 418000 times.
✓ Branch 1 taken 2375 times.
420375 for(int32_t k=0; k<176; ++k)
17263 {
17264
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 418000 times.
418000 if(!p_getc(&(temp_mapscr->cset[k]),f,true))
17265 return qe_invalid;
17266 418000 }
17267 2375 }
17268
2/2
✓ Branch 0 taken 5232 times.
✓ Branch 1 taken 2 times.
5234 if(scr_has_flags & SCRHAS_MISC)
17269 {
17270
1/2
✓ Branch 0 taken 5232 times.
✗ Branch 1 not taken.
5232 if(!p_igetw(&(temp_mapscr->color),f,true))
17271 return qe_invalid;
17272
1/2
✓ Branch 0 taken 5232 times.
✗ Branch 1 not taken.
5232 if(!p_getc(&(temp_mapscr->csensitive),f,true))
17273 return qe_invalid;
17274
1/2
✓ Branch 0 taken 5232 times.
✗ Branch 1 not taken.
5232 if(!p_getc(&(temp_mapscr->oceansfx),f,true))
17275 return qe_invalid;
17276
1/2
✓ Branch 0 taken 5232 times.
✗ Branch 1 not taken.
5232 if(!p_getc(&(temp_mapscr->bosssfx),f,true))
17277 return qe_invalid;
17278
1/2
✓ Branch 0 taken 5232 times.
✗ Branch 1 not taken.
5232 if(!p_getc(&(temp_mapscr->secretsfx),f,true))
17279 return qe_invalid;
17280
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5232 times.
5232 if(!p_getc(&(temp_mapscr->holdupsfx),f,true))
17281 return qe_invalid;
17282
1/2
✓ Branch 0 taken 5232 times.
✗ Branch 1 not taken.
5232 if(!p_igetw(&(temp_mapscr->timedwarptics),f,true))
17283 return qe_invalid;
17284
1/2
✓ Branch 0 taken 5232 times.
✗ Branch 1 not taken.
5232 if(!p_igetw(&(temp_mapscr->screen_midi),f,true))
17285 return qe_invalid;
17286
1/2
✓ Branch 0 taken 5232 times.
✗ Branch 1 not taken.
5232 if(!p_getc(&(temp_mapscr->lens_layer),f,true))
17287 return qe_invalid;
17288 5232 }
17289 else
17290 {
17291 2 temp_mapscr->screen_midi = -1;
17292 2 temp_mapscr->csensitive = 1;
17293 }
17294 //FFC
17295 5234 bool old_ff = version < 25;
17296 5234 dword bits = 0;
17297 5234 word numffc = 32;
17298
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 5157 times.
5234 if(old_ff)
17299 {
17300
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetl(&bits,f,true))
17301 return qe_invalid;
17302 77 }
17303 else
17304 {
17305
1/2
✓ Branch 0 taken 5157 times.
✗ Branch 1 not taken.
5157 if(!p_igetw(&numffc,f,true))
17306 return qe_invalid;
17307 }
17308 byte tempbyte;
17309 word tempw;
17310
4/6
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 5215 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 19 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 19 times.
5234 static ffcdata nil_ffc;
17311 5234 temp_mapscr->ffcCountMarkDirty();
17312
2/2
✓ Branch 0 taken 5234 times.
✓ Branch 1 taken 8545 times.
13779 for(word m = 0; m < numffc; ++m)
17313 {
17314
1/2
✓ Branch 0 taken 8545 times.
✗ Branch 1 not taken.
8545 ffcdata& tempffc = (m < MAXFFCS)
17315 8545 ? temp_mapscr->ffcs[m]
17316 : nil_ffc; //sanity
17317 8545 tempffc.clear();
17318
3/4
✓ Branch 0 taken 2464 times.
✓ Branch 1 taken 6081 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2464 times.
8545 if(old_ff && !(bits & (1<<m))) continue;
17319
17320
1/2
✓ Branch 0 taken 6081 times.
✗ Branch 1 not taken.
6081 if(!p_igetw(&tempw,f,true))
17321 return qe_invalid;
17322
3/4
✓ Branch 0 taken 6081 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 965 times.
✓ Branch 3 taken 5116 times.
6081 if(!old_ff && !tempw) //empty ffc, nothing more to load
17323 5116 continue;
17324 965 tempffc.setData(tempw);
17325
17326
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_getc(&(tempffc.cset),f,true))
17327 return qe_invalid;
17328
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_igetw(&(tempffc.delay),f,true))
17329 return qe_invalid;
17330
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_igetzf(&(tempffc.x),f,true))
17331 return qe_invalid;
17332
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_igetzf(&(tempffc.y),f,true))
17333 return qe_invalid;
17334
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_igetzf(&(tempffc.vx),f,true))
17335 return qe_invalid;
17336
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_igetzf(&(tempffc.vy),f,true))
17337 return qe_invalid;
17338
1/2
✓ Branch 0 taken 965 times.
✗ Branch 1 not taken.
965 if(!p_igetzf(&(tempffc.ax),f,true))
17339 return qe_invalid;
17340
1/2
✓ Branch 0 taken 965 times.
✗ Branch 1 not taken.
965 if(!p_igetzf(&(tempffc.ay),f,true))
17341 return qe_invalid;
17342
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_getc(&(tempffc.link),f,true))
17343 return qe_invalid;
17344
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(version < 24)
17345 {
17346 if(!p_getc(&tempbyte,f,true))
17347 return qe_invalid;
17348 tempffc.hxsz = (tempbyte&0x3F)+1;
17349 tempffc.txsz = (tempbyte>>6)+1;
17350 if(!p_getc(&tempbyte,f,true))
17351 return qe_invalid;
17352 tempffc.hysz = (tempbyte&0x3F)+1;
17353 tempffc.tysz = (tempbyte>>6)+1;
17354 }
17355 else
17356 {
17357
1/2
✓ Branch 0 taken 965 times.
✗ Branch 1 not taken.
965 if(!p_igetl(&(tempffc.hxsz),f,true))
17358 return qe_invalid;
17359
1/2
✓ Branch 0 taken 965 times.
✗ Branch 1 not taken.
965 if(!p_igetl(&(tempffc.hysz),f,true))
17360 return qe_invalid;
17361
1/2
✓ Branch 0 taken 965 times.
✗ Branch 1 not taken.
965 if(!p_getc(&(tempffc.txsz),f,true))
17362 return qe_invalid;
17363
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_getc(&(tempffc.tysz),f,true))
17364 return qe_invalid;
17365 }
17366
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_igetl(&(tempffc.flags),f,true))
17367 return qe_invalid;
17368 965 tempffc.updateSolid();
17369
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_igetw(&(tempffc.script),f,true))
17370 return qe_invalid;
17371
2/2
✓ Branch 0 taken 7720 times.
✓ Branch 1 taken 965 times.
8685 for(auto q = 0; q < 8; ++q)
17372 {
17373
1/2
✓ Branch 0 taken 7720 times.
✗ Branch 1 not taken.
7720 if(!p_igetl(&(tempffc.initd[q]),f,true))
17374 return qe_invalid;
17375 7720 }
17376
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_getc(&(tempbyte),f,true))
17377 return qe_invalid;
17378 965 tempffc.inita[0]=tempbyte*10000;
17379
17380
1/2
✓ Branch 0 taken 965 times.
✗ Branch 1 not taken.
965 if(!p_getc(&(tempbyte),f,true))
17381 return qe_invalid;
17382 965 tempffc.inita[1]=tempbyte*10000;
17383
17384 965 tempffc.initialized = false;
17385 965 }
17386
2/2
✓ Branch 0 taken 661407 times.
✓ Branch 1 taken 5234 times.
666641 for(word m = numffc; m < MAXFFCS; ++m)
17387 {
17388 661407 temp_mapscr->ffcs[m].clear();
17389 661407 }
17390 //END FFC
17391 }
17392 150210 return 0;
17393 157216 }
17394
17395
17396 99 int32_t readmaps(PACKFILE *f, zquestheader *Header, bool keepdata)
17397 {
17398 99 int32_t scr=0;
17399
17400 99 word version=0;
17401 dword dummy;
17402 int32_t screens_to_read;
17403
17404 99 mapscr temp_mapscr;
17405 zcmap temp_map;
17406 word temp_map_count;
17407 dword section_size;
17408
17409
2/6
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17410 {
17411 screens_to_read=MAPSCRS192b136;
17412 }
17413 else
17414 {
17415 99 screens_to_read=MAPSCRS;
17416 }
17417
17418
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(Header->zelda_version > 0x192)
17419 {
17420 //section version info
17421
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&version,f,true))
17422 {
17423 return qe_invalid;
17424 }
17425
17426 99 FFCore.quest_format[vMaps] = version;
17427
17428 //al_trace("Maps version %d\n", version);
17429
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&dummy,f,true))
17430 {
17431 return qe_invalid;
17432 }
17433
17434 //section size
17435
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetl(&section_size,f,true))
17436 {
17437 return qe_invalid;
17438 }
17439
17440 //finally... section data
17441
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(!p_igetw(&temp_map_count,f,true))
17442 {
17443 return 5;
17444 }
17445 99 }
17446 else
17447 {
17448 temp_map_count=map_count;
17449 }
17450
17451
17452
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata)
17453 {
17454 99 const int32_t _mapsSize = MAPSCRS*temp_map_count;
17455 99 TheMaps.resize(_mapsSize);
17456
17457
2/2
✓ Branch 0 taken 158168 times.
✓ Branch 1 taken 99 times.
158267 for(int32_t i(0); i<_mapsSize; i++)
17458 158168 TheMaps[i].zero_memory();
17459
17460 // Used to be done for each screen
17461
2/2
✓ Branch 0 taken 12672 times.
✓ Branch 1 taken 99 times.
12771 for(int32_t i=0; i<MAXFFCS; i++)
17462 {
17463 12672 ffcScriptData[i].a[0] = 10000;
17464 12672 ffcScriptData[i].a[1] = 10000;
17465 12672 }
17466
17467 99 memset(ZCMaps, 0, sizeof(zcmap)*MAXMAPS2);
17468 99 }
17469
17470 99 temp_mapscr.zero_memory();
17471
17472 99 memset(&temp_map, 0, sizeof(zcmap));
17473 99 temp_map.scrResWidth = 256;
17474 99 temp_map.scrResHeight = 224;
17475 99 temp_map.tileWidth = 16;
17476 99 temp_map.tileHeight = 11;
17477 99 temp_map.viewWidth = 256;
17478 99 temp_map.viewHeight = 176;
17479 99 temp_map.viewX = 0;
17480 99 temp_map.viewY = 64;
17481 99 temp_map.subaWidth = 256;
17482 99 temp_map.subaHeight = 168;
17483 99 temp_map.subaTrans = false;
17484 99 temp_map.subpWidth = 256;
17485 99 temp_map.subpHeight = 56;
17486 99 temp_map.subpTrans = false;
17487
4/4
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 1163 times.
✓ Branch 2 taken 1163 times.
✓ Branch 3 taken 99 times.
1262 for(int32_t i=0; i<temp_map_count && i<MAXMAPS2; i++)
17488 {
17489
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1163 times.
1163 if(keepdata==true) //!TODO Trim fully
17490 {
17491 1163 memcpy(&ZCMaps[i], &temp_map, sizeof(zcmap));
17492 1163 }
17493 1163 byte valid=1;
17494
2/2
✓ Branch 0 taken 1066 times.
✓ Branch 1 taken 97 times.
1163 if(version > 22)
17495 {
17496
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(!p_getc(&valid,f,true))
17497 return qe_invalid;
17498 97 }
17499
2/2
✓ Branch 0 taken 158168 times.
✓ Branch 1 taken 1163 times.
159331 for(int32_t j=0; j<screens_to_read; j++)
17500 {
17501 158168 scr=i*MAPSCRS+j;
17502 158168 clear_screen(&temp_mapscr);
17503
2/2
✓ Branch 0 taken 952 times.
✓ Branch 1 taken 157216 times.
158168 if(valid)
17504 157216 readmapscreen(f, Header, &temp_mapscr, &temp_map, version);
17505
17506
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 158168 times.
158168 if(keepdata==true)
17507 {
17508 158168 TheMaps[scr] = temp_mapscr;
17509 158168 }
17510 158168 }
17511
17512
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1163 times.
1163 if(keepdata==true)
17513 {
17514
2/6
✓ Branch 0 taken 1163 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1163 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1163 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17515 {
17516 int32_t index = (i*MAPSCRS+132);
17517
17518 TheMaps[index]=TheMaps[index-1];
17519
17520 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].data, TheMaps[i*MAPSCRS+131].data);
17521 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].sflag, TheMaps[i*MAPSCRS+131].sflag);
17522 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].cset, TheMaps[i*MAPSCRS+131].cset);
17523
17524 for(int32_t j=133; j<MAPSCRS; j++)
17525 {
17526 scr=i*MAPSCRS+j;
17527
17528 TheMaps[scr].zero_memory();
17529 TheMaps[scr].valid = mVERSION;
17530 TheMaps[scr].screen_midi = -1;
17531 TheMaps[scr].csensitive = 1;
17532 }
17533 }
17534
17535
2/6
✓ Branch 0 taken 1163 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1163 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1163 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
17536 {
17537 for(int32_t j=0; j<MAPSCRS; j++)
17538 {
17539 scr=i*MAPSCRS+j;
17540 TheMaps[scr].door_combo_set=MakeDoors(i, j);
17541
17542 for(int32_t k=0; k<128; k++)
17543 {
17544 TheMaps[scr].secretcset[k]=tcmbcset2(i, TheMaps[scr].secretcombo[k]);
17545 TheMaps[scr].secretflag[k]=tcmbflag2(i, TheMaps[scr].secretcombo[k]);
17546 TheMaps[scr].secretcombo[k]=tcmbdat2(i, j, TheMaps[scr].secretcombo[k]);
17547 }
17548 }
17549 }
17550 1163 }
17551 1163 }
17552
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata)
17553 {
17554 99 map_count = temp_map_count;
17555 99 }
17556 99 clear_screen(&temp_mapscr);
17557 99 return 0;
17558 99 }
17559
17560
17561 79 int32_t readcombos_old(word section_version, PACKFILE *f, zquestheader *, word version, word build, word start_combo, word max_combos, bool keepdata)
17562 {
17563 79 reset_combo_animations();
17564 79 reset_combo_animations2();
17565
17566 79 init_combo_classes();
17567
17568 // combos
17569 79 word combos_used=0;
17570 int32_t dummy;
17571 byte padding;
17572 79 newcombo temp_combo;
17573 //word section_cversion=0;
17574
17575
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
79 if(keepdata==true)
17576 {
17577
2/2
✓ Branch 0 taken 5157120 times.
✓ Branch 1 taken 79 times.
5157199 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
17578 5157120 combobuf[q].clear();
17579 79 }
17580
17581 // if(version > 0x192)
17582 // {
17583 // //section version info
17584 // if(!p_igetw(&section_version,f,true))
17585 // {
17586 // return qe_invalid;
17587 // }
17588
17589 // FFCore.quest_format[vCombos] = section_version;
17590
17591 // //al_trace("Combos version %d\n", section_version);
17592 // if(!p_igetw(&section_cversion,f,true))
17593 // {
17594 // return qe_invalid;
17595 // }
17596
17597 // //section size
17598 // if(!p_igetl(&dummy,f,true))
17599 // {
17600 // return qe_invalid;
17601 // }
17602 // }
17603
17604
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
79 if(version < 0x174)
17605 {
17606 combos_used=1024;
17607 }
17608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
79 else if(version < 0x191)
17609 {
17610 combos_used=2048;
17611 }
17612 else
17613 {
17614
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 if(!p_igetw(&combos_used,f,true))
17615 {
17616 return qe_invalid;
17617 }
17618 }
17619
17620 //finally... section data
17621
2/2
✓ Branch 0 taken 367401 times.
✓ Branch 1 taken 79 times.
367480 for(int32_t i=0; i<combos_used; i++)
17622 {
17623 367401 temp_combo.clear();
17624
17625
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 298517 times.
367401 if ( section_version >= 11 )
17626 {
17627
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(!p_igetl(&temp_combo.tile,f,true))
17628 {
17629 return qe_invalid;
17630 }
17631 68884 }
17632 else
17633 {
17634
1/2
✓ Branch 0 taken 298517 times.
✗ Branch 1 not taken.
298517 if(!p_igetw(&temp_combo.tile,f,true))
17635 {
17636 return qe_invalid;
17637 }
17638 }
17639 367401 temp_combo.o_tile = temp_combo.tile;
17640
1/2
✓ Branch 0 taken 367401 times.
✗ Branch 1 not taken.
367401 if(!p_getc(&temp_combo.flip,f,true))
17641 {
17642 return qe_invalid;
17643 }
17644
17645
1/2
✓ Branch 0 taken 367401 times.
✗ Branch 1 not taken.
367401 if(!p_getc(&temp_combo.walk,f,true))
17646 {
17647 return qe_invalid;
17648 }
17649
17650
1/2
✓ Branch 0 taken 367401 times.
✗ Branch 1 not taken.
367401 if(!p_getc(&temp_combo.type,f,true))
17651 {
17652 return qe_invalid;
17653 }
17654
17655
1/2
✓ Branch 0 taken 367401 times.
✗ Branch 1 not taken.
367401 if(!p_getc(&temp_combo.csets,f,true))
17656 {
17657 return qe_invalid;
17658 }
17659
17660
1/2
✓ Branch 0 taken 367401 times.
✗ Branch 1 not taken.
367401 if(version < 0x193)
17661 {
17662 if(!p_getc(&padding,f,true))
17663 {
17664 return qe_invalid;
17665 }
17666
17667 if(!p_getc(&padding,f,true))
17668 {
17669 return qe_invalid;
17670 }
17671
17672 if(version < 0x192)
17673 {
17674 if(version == 0x191)
17675 {
17676 for(int32_t tmpcounter=0; tmpcounter<16; tmpcounter++)
17677 {
17678 if(!p_getc(&padding,f,true))
17679 {
17680 return qe_invalid;
17681 }
17682 }
17683 }
17684
17685 if(keepdata==true)
17686 {
17687 memcpy(&combobuf[i], &temp_combo, sizeof(temp_combo));
17688 }
17689
17690 continue;
17691 }
17692 }
17693
17694
1/2
✓ Branch 0 taken 367401 times.
✗ Branch 1 not taken.
367401 if(!p_getc(&temp_combo.frames,f,true))
17695 {
17696 return qe_invalid;
17697 }
17698
17699
1/2
✓ Branch 0 taken 367401 times.
✗ Branch 1 not taken.
367401 if(!p_getc(&temp_combo.speed,f,true))
17700 {
17701 return qe_invalid;
17702 }
17703
17704
1/2
✓ Branch 0 taken 367401 times.
✗ Branch 1 not taken.
367401 if(!p_igetw(&temp_combo.nextcombo,f,true))
17705 {
17706 return qe_invalid;
17707 }
17708
17709
1/2
✓ Branch 0 taken 367401 times.
✗ Branch 1 not taken.
367401 if(!p_getc(&temp_combo.nextcset,f,true))
17710 {
17711 return qe_invalid;
17712 }
17713
17714 //Base flag
17715
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 360207 times.
367401 if(section_version>=3)
17716 {
17717
1/2
✓ Branch 0 taken 360207 times.
✗ Branch 1 not taken.
360207 if(!p_getc(&temp_combo.flag,f,true))
17718 {
17719 return qe_invalid;
17720 }
17721 360207 }
17722
17723
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 360207 times.
367401 if(section_version>=4)
17724 {
17725
1/2
✓ Branch 0 taken 360207 times.
✗ Branch 1 not taken.
360207 if(!p_getc(&temp_combo.skipanim,f,true))
17726 {
17727 return qe_invalid;
17728 }
17729
17730
1/2
✓ Branch 0 taken 360207 times.
✗ Branch 1 not taken.
360207 if(!p_igetw(&temp_combo.nexttimer,f,true))
17731 {
17732 return qe_invalid;
17733 }
17734 360207 }
17735
17736
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 360207 times.
367401 if(section_version>=5)
17737 {
17738
1/2
✓ Branch 0 taken 360207 times.
✗ Branch 1 not taken.
360207 if(!p_getc(&temp_combo.skipanimy,f,true))
17739 {
17740 return qe_invalid;
17741 }
17742 360207 }
17743
17744
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 360207 times.
367401 if(section_version>=6)
17745 {
17746
1/2
✓ Branch 0 taken 360207 times.
✗ Branch 1 not taken.
360207 if(!p_getc(&temp_combo.animflags,f,true))
17747 {
17748 return qe_invalid;
17749 }
17750
17751
1/2
✓ Branch 0 taken 360207 times.
✗ Branch 1 not taken.
360207 if(section_version == 6)
17752 temp_combo.animflags = temp_combo.animflags ? AF_FRESH : 0;
17753 360207 }
17754
17755
2/2
✓ Branch 0 taken 298517 times.
✓ Branch 1 taken 68884 times.
367401 if(section_version>=8) //combo Attributes[4] and userflags.
17756 {
17757
2/2
✓ Branch 0 taken 275536 times.
✓ Branch 1 taken 68884 times.
344420 for ( int32_t q = 0; q < NUM_COMBO_ATTRIBUTES; q++ )
17758 {
17759
1/2
✓ Branch 0 taken 275536 times.
✗ Branch 1 not taken.
275536 if(!p_igetl(&temp_combo.attributes[q],f,true))
17760 {
17761 return qe_invalid;
17762 }
17763 275536 }
17764
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(!p_igetl(&temp_combo.usrflags,f,true))
17765 {
17766 return qe_invalid;
17767 }
17768
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(section_version >= 20)
17769 {
17770
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(!p_igetw(&temp_combo.genflags,f,true))
17771 {
17772 return qe_invalid;
17773 }
17774 68884 }
17775 else
17776 {
17777 temp_combo.genflags = 0;
17778 switch(temp_combo.type)
17779 {
17780 case cPUSH_WAIT: case cPUSH_HEAVY:
17781 case cPUSH_HW: case cL_STATUE:
17782 case cR_STATUE: case cPUSH_HEAVY2:
17783 case cPUSH_HW2: case cPOUND:
17784 case cC_STATUE: case cMIRROR:
17785 case cMIRRORSLASH: case cMIRRORBACKSLASH:
17786 case cMAGICPRISM: case cMAGICPRISM4:
17787 case cMAGICSPONGE: case cEYEBALL_A:
17788 case cEYEBALL_B: case cEYEBALL_4:
17789 case cBUSH: case cFLOWERS:
17790 case cLOCKBLOCK: case cLOCKBLOCK2:
17791 case cBOSSLOCKBLOCK: case cBOSSLOCKBLOCK2:
17792 case cCHEST: case cCHEST2:
17793 case cLOCKEDCHEST: case cLOCKEDCHEST2:
17794 case cBOSSCHEST: case cBOSSCHEST2:
17795 case cBUSHNEXT: case cBUSHTOUCHY:
17796 case cFLOWERSTOUCHY: case cBUSHNEXTTOUCHY:
17797 case cSIGNPOST: case cCSWITCHBLOCK:
17798 case cTORCH: case cTRIGGERGENERIC:
17799 if(temp_combo.usrflags & cflag16)
17800 {
17801 temp_combo.genflags |= cflag1;
17802 temp_combo.usrflags &= ~cflag16;
17803 }
17804 break; }
17805 }
17806 68884 }
17807
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 298517 times.
367401 if(section_version>=10) //combo trigger flags
17808 {
17809
2/2
✓ Branch 0 taken 206652 times.
✓ Branch 1 taken 68884 times.
275536 for ( int32_t q = 0; q < 3; q++ )
17810 {
17811
1/2
✓ Branch 0 taken 206652 times.
✗ Branch 1 not taken.
206652 if(!p_igetl(&temp_combo.triggerflags[q],f,true))
17812 {
17813 return qe_invalid;
17814 }
17815 206652 }
17816 68884 }
17817
1/2
✓ Branch 0 taken 298517 times.
✗ Branch 1 not taken.
298517 else if(section_version==9) //combo trigger flags, V9 only had two indices of triggerflags[]
17818 {
17819 for ( int32_t q = 0; q < 2; q++ )
17820 {
17821 if(!p_igetl(&temp_combo.triggerflags[q],f,true))
17822 {
17823 return qe_invalid;
17824 }
17825 }
17826 }
17827
2/2
✓ Branch 0 taken 298517 times.
✓ Branch 1 taken 68884 times.
367401 if(section_version >= 9)
17828 {
17829
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(!p_igetl(&temp_combo.triggerlevel,f,true))
17830 {
17831 return qe_invalid;
17832 }
17833 68884 }
17834
2/2
✓ Branch 0 taken 298517 times.
✓ Branch 1 taken 68884 times.
367401 if(section_version >= 22)
17835 {
17836
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(!p_getc(&temp_combo.triggerbtn,f,true))
17837 {
17838 return qe_invalid;
17839 }
17840 68884 }
17841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 367401 times.
367401 if(section_version < 23)
17842 {
17843
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 367253 times.
367401 switch(temp_combo.type) //combotriggerCMBTYPEFX now required for combotype-specific effects
17844 {
17845 case cSCRIPT1: case cSCRIPT2: case cSCRIPT3: case cSCRIPT4: case cSCRIPT5:
17846 case cSCRIPT6: case cSCRIPT7: case cSCRIPT8: case cSCRIPT9: case cSCRIPT10:
17847 case cTRIGGERGENERIC: case cCSWITCH:
17848 148 temp_combo.triggerflags[0] |= combotriggerCMBTYPEFX;
17849 148 }
17850 367401 }
17851
1/2
✓ Branch 0 taken 367401 times.
✗ Branch 1 not taken.
367401 if(section_version >= 24)
17852 {
17853 if(!p_getc(&temp_combo.triggeritem,f,true))
17854 {
17855 return qe_invalid;
17856 }
17857 if(!p_getc(&temp_combo.trigtimer,f,true))
17858 {
17859 return qe_invalid;
17860 }
17861 }
17862
1/2
✓ Branch 0 taken 367401 times.
✗ Branch 1 not taken.
367401 if(section_version >= 25)
17863 {
17864 if(!p_getc(&temp_combo.trigsfx,f,true))
17865 {
17866 return qe_invalid;
17867 }
17868 }
17869
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 367401 times.
367401 if(section_version >= 27)
17870 {
17871 if(!p_igetl(&temp_combo.trigchange,f,true))
17872 {
17873 return qe_invalid;
17874 }
17875 }
17876 else
17877 {
17878
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 367401 times.
367401 if(temp_combo.triggerflags[0] & 0x00040000) //'next'
17879 temp_combo.trigchange = 1;
17880
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 367401 times.
367401 else if(temp_combo.triggerflags[0] & 0x00080000) //'prev'
17881 temp_combo.trigchange = -1;
17882 367401 else temp_combo.trigchange = 0;
17883 367401 temp_combo.triggerflags[0] &= ~(0x00040000|0x00080000);
17884 }
17885
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 367401 times.
367401 if(section_version >= 29)
17886 {
17887 if(!p_igetw(&temp_combo.trigprox,f,true))
17888 {
17889 return qe_invalid;
17890 }
17891 if(!p_getc(&temp_combo.trigctr,f,true))
17892 {
17893 return qe_invalid;
17894 }
17895 if(!p_igetl(&temp_combo.trigctramnt,f,true))
17896 {
17897 return qe_invalid;
17898 }
17899 }
17900 else
17901 {
17902 367401 temp_combo.trigprox = 0;
17903 367401 temp_combo.trigctr = 0;
17904 367401 temp_combo.trigctramnt = 0;
17905 }
17906
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 367401 times.
367401 if(section_version >= 30)
17907 {
17908 if(!p_getc(&temp_combo.triglbeam,f,true))
17909 {
17910 return qe_invalid;
17911 }
17912 }
17913 367401 else temp_combo.triglbeam = 0;
17914
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 367401 times.
367401 if(section_version >= 31)
17915 {
17916 if(!p_getc(&temp_combo.trigcschange,f,true))
17917 {
17918 return qe_invalid;
17919 }
17920 if(!p_igetw(&temp_combo.spawnitem,f,true))
17921 {
17922 return qe_invalid;
17923 }
17924 if(!p_igetw(&temp_combo.spawnenemy,f,true))
17925 {
17926 return qe_invalid;
17927 }
17928 if(!p_getc(&temp_combo.exstate,f,true))
17929 {
17930 return qe_invalid;
17931 }
17932 if(!p_igetl(&temp_combo.spawnip,f,true))
17933 {
17934 return qe_invalid;
17935 }
17936 if(!p_getc(&temp_combo.trigcopycat,f,true))
17937 {
17938 return qe_invalid;
17939 }
17940 }
17941 else
17942 {
17943 367401 temp_combo.trigcschange = 0;
17944 367401 temp_combo.spawnitem = 0;
17945 367401 temp_combo.spawnenemy = 0;
17946 367401 temp_combo.exstate = -1;
17947 367401 temp_combo.spawnip = 0;
17948 367401 temp_combo.trigcopycat = 0;
17949 }
17950
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 367401 times.
367401 if(section_version >= 32)
17951 {
17952 if(!p_getc(&temp_combo.trigcooldown,f,true))
17953 {
17954 return qe_invalid;
17955 }
17956 }
17957 else
17958 {
17959 367401 temp_combo.trigcooldown = 0;
17960 }
17961
17962
2/2
✓ Branch 0 taken 298517 times.
✓ Branch 1 taken 68884 times.
367401 if(section_version>=12) //combo label
17963 {
17964
2/2
✓ Branch 0 taken 757724 times.
✓ Branch 1 taken 68884 times.
826608 for ( int32_t q = 0; q < 11; q++ )
17965 {
17966
1/2
✓ Branch 0 taken 757724 times.
✗ Branch 1 not taken.
757724 if(!p_getc(&temp_combo.label[q],f,true))
17967 {
17968 return qe_invalid;
17969 }
17970 757724 }
17971 68884 }
17972
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 298517 times.
367401 if(section_version<12) //combo label
17973 {
17974
2/2
✓ Branch 0 taken 3283687 times.
✓ Branch 1 taken 298517 times.
3582204 for ( int32_t q = 0; q < 11; q++ )
17975 {
17976 3283687 temp_combo.label[q] = 0;
17977 3283687 }
17978 298517 }
17979 //al_trace("Read combo label\n");
17980
2/2
✓ Branch 0 taken 298517 times.
✓ Branch 1 taken 68884 times.
367401 if(section_version>=13) //attribytes[4]
17981 {
17982
2/2
✓ Branch 0 taken 275536 times.
✓ Branch 1 taken 68884 times.
344420 for ( int32_t q = 0; q < 4; q++ ) //Bad Zoria, don't mix constants with hardcodes
17983 {
17984
1/2
✓ Branch 0 taken 275536 times.
✗ Branch 1 not taken.
275536 if(!p_getc(&temp_combo.attribytes[q],f,true))
17985 {
17986 return qe_invalid;
17987 }
17988 275536 }
17989
17990 68884 }
17991 //al_trace("Read combo attribytes\n");
17992
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 298517 times.
367401 if( section_version < 13 )
17993 {
17994
2/2
✓ Branch 0 taken 1194068 times.
✓ Branch 1 taken 298517 times.
1492585 for ( int32_t q = 0; q < NUM_COMBO_ATTRIBUTES; q++ )
17995 {
17996 1194068 temp_combo.attribytes[q] = 0;
17997 1194068 }
17998
17999 298517 }
18000 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
18001 * This fixes a poor implementation of a ->next flag bug thing.
18002 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
18003 * there was a version bump a few weeks before a change that broke stuff.
18004 */
18005
3/4
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 298517 times.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
367401 if (section_version >= 13 && section_version < 21)
18006 {
18007 set_bit(quest_rules,qr_BUGGY_BUGGY_SLASH_TRIGGERS,1);
18008 }
18009 //combo scripts
18010
2/2
✓ Branch 0 taken 298517 times.
✓ Branch 1 taken 68884 times.
367401 if(section_version>=14)
18011 {
18012
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(!p_igetw(&temp_combo.script,f,true)) return qe_invalid;
18013
2/2
✓ Branch 0 taken 137768 times.
✓ Branch 1 taken 68884 times.
206652 for ( int32_t q = 0; q < 2; q++ )
18014 {
18015
1/2
✓ Branch 0 taken 137768 times.
✗ Branch 1 not taken.
137768 if(!p_igetl(&temp_combo.initd[q],f,true))
18016 {
18017 return qe_invalid;
18018 }
18019 137768 }
18020
18021 68884 }
18022
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 298517 times.
367401 if(section_version<14)
18023 {
18024 298517 temp_combo.script = 0;
18025
2/2
✓ Branch 0 taken 597034 times.
✓ Branch 1 taken 298517 times.
895551 for ( int32_t q = 0; q < 2; q++ )
18026 {
18027 597034 temp_combo.initd[q] = 0;
18028 597034 }
18029 298517 }
18030 //al_trace("Read combo script data\n");
18031
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 298517 times.
367401 if(section_version>=15)
18032 {
18033
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(!p_igetl(&temp_combo.o_tile,f,true)) return qe_invalid;
18034
2/2
✓ Branch 0 taken 37028 times.
✓ Branch 1 taken 31856 times.
68884 if(!temp_combo.o_tile) temp_combo.o_tile = temp_combo.tile;
18035
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(!p_getc(&temp_combo.cur_frame,f,true)) return qe_invalid;
18036
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(!p_getc(&temp_combo.aclk,f,true)) return qe_invalid;
18037 68884 }
18038 else
18039 {
18040 298517 temp_combo.o_tile = temp_combo.tile;
18041 298517 temp_combo.cur_frame = 0;
18042 298517 temp_combo.aclk = 0;
18043 }
18044
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 298517 times.
367401 if(section_version>=17) //attribytes[4]
18045 {
18046
2/2
✓ Branch 0 taken 275536 times.
✓ Branch 1 taken 68884 times.
344420 for ( int32_t q = 4; q < 8; q++ ) //bump up attribytes...
18047 {
18048
1/2
✓ Branch 0 taken 275536 times.
✗ Branch 1 not taken.
275536 if(!p_getc(&temp_combo.attribytes[q],f,true))
18049 {
18050 return qe_invalid;
18051 }
18052 275536 }
18053
2/2
✓ Branch 0 taken 551072 times.
✓ Branch 1 taken 68884 times.
619956 for ( int32_t q = 0; q < 8; q++ ) //...and add attrishorts
18054 {
18055
1/2
✓ Branch 0 taken 551072 times.
✗ Branch 1 not taken.
551072 if(!p_igetw(&temp_combo.attrishorts[q],f,true))
18056 {
18057 return qe_invalid;
18058 }
18059 551072 }
18060
18061 68884 }
18062 else
18063 {
18064
2/2
✓ Branch 0 taken 1194068 times.
✓ Branch 1 taken 298517 times.
1492585 for ( int32_t q = 4; q < 8; q++ ) //bump up attribytes...
18065 {
18066 1194068 temp_combo.attribytes[q] = 0;
18067 1194068 }
18068
2/2
✓ Branch 0 taken 2388136 times.
✓ Branch 1 taken 298517 times.
2686653 for ( int32_t q = 0; q < 8; q++ ) //...and add attrishorts
18069 {
18070 2388136 temp_combo.attrishorts[q] = 0;
18071 2388136 }
18072 }
18073
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 298517 times.
367401 if(section_version<18) //upper bits for .walk
18074 {
18075 298517 temp_combo.walk |= 0xF0; //All on by default for old quests -E
18076 298517 }
18077
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 298517 times.
367401 if(section_version < 19)
18078 {
18079
2/2
✓ Branch 0 taken 1194068 times.
✓ Branch 1 taken 298517 times.
1492585 for(int32_t q = 0; q < 4; ++q)
18080 {
18081 1194068 temp_combo.attributes[q] *= 10000L;
18082 1194068 }
18083 298517 }
18084
18085
1/2
✓ Branch 0 taken 367401 times.
✗ Branch 1 not taken.
367401 if(version < 0x193)
18086 {
18087 for(int32_t q=0; q<11; q++)
18088 {
18089 if(!p_getc(&dummy,f,true))
18090 {
18091 return qe_invalid;
18092 }
18093 }
18094 }
18095
18096 //Goriya tiles were flipped around in 2.11 build 7. Compensate for the flip here. -DD
18097
3/6
✓ Branch 0 taken 360207 times.
✓ Branch 1 taken 7194 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 360207 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
367401 if((version < 0x211)||((version == 0x211)&&(build<7)))
18098 {
18099
1/2
✓ Branch 0 taken 7194 times.
✗ Branch 1 not taken.
7194 if(!get_bit(quest_rules,qr_NEWENEMYTILES))
18100 {
18101 switch(temp_combo.tile)
18102 {
18103 case 130:
18104 temp_combo.tile = 132;
18105 break;
18106
18107 case 131:
18108 temp_combo.tile = 133;
18109 break;
18110
18111 case 132:
18112 temp_combo.tile = 130;
18113 break;
18114
18115 case 133:
18116 temp_combo.tile = 131;
18117 break;
18118 }
18119 }
18120 7194 }
18121
18122
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 367401 times.
367401 if(section_version < 25)
18123 {
18124
2/2
✓ Branch 0 taken 2517 times.
✓ Branch 1 taken 364884 times.
367401 switch(temp_combo.type)
18125 {
18126 case cLOCKBLOCK: case cBOSSLOCKBLOCK:
18127
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2517 times.
2517 if(!(temp_combo.usrflags & cflag3))
18128 2517 temp_combo.attribytes[3] = WAV_DOOR;
18129 2517 temp_combo.usrflags &= ~cflag3;
18130 2517 break;
18131 }
18132 367401 }
18133
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 367401 times.
367401 if(section_version < 26)
18134 {
18135
2/2
✓ Branch 0 taken 366902 times.
✓ Branch 1 taken 499 times.
367401 if(temp_combo.type == cARMOS)
18136 {
18137
1/2
✓ Branch 0 taken 499 times.
✗ Branch 1 not taken.
499 if(temp_combo.usrflags & cflag1)
18138 temp_combo.usrflags |= cflag3;
18139 499 }
18140 367401 }
18141
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 367401 times.
367401 if(section_version < 28)
18142 {
18143
2/2
✓ Branch 0 taken 1316 times.
✓ Branch 1 taken 366085 times.
367401 switch(temp_combo.type)
18144 {
18145 case cLOCKBLOCK: case cLOCKEDCHEST:
18146
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1316 times.
1316 if(temp_combo.usrflags & cflag7)
18147 temp_combo.usrflags |= cflag8;
18148 1316 else temp_combo.usrflags &= ~cflag8;
18149 1316 temp_combo.usrflags &= ~cflag7;
18150 1316 break;
18151 }
18152
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 367332 times.
367401 switch(temp_combo.type)
18153 {
18154 case cCHEST: case cLOCKEDCHEST: case cBOSSCHEST:
18155 69 temp_combo.attrishorts[2] = -1;
18156 69 temp_combo.usrflags |= cflag7;
18157 69 break;
18158 }
18159 367401 }
18160
18161
2/4
✓ Branch 0 taken 367401 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 367401 times.
367401 if(keepdata==true && i>=start_combo)
18162 {
18163 367401 memcpy(&combobuf[i], &temp_combo, sizeof(temp_combo));
18164 367401 }
18165 367401 }
18166
18167
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
79 if(keepdata==true)
18168 {
18169
2/6
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 79 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
79 if((version < 0x192)|| ((version == 0x192)&&(build<185)))
18170 {
18171 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18172 {
18173 if(combobuf[tmpcounter].type==cHOOKSHOTONLY)
18174 {
18175 combobuf[tmpcounter].type=cLADDERHOOKSHOT;
18176 }
18177 }
18178 }
18179
18180 //June 3 2012; ladder only is broken in 2.10 and allows the hookshot also. -Gleeok
18181
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
79 if(version == 0x210 && !is_zquest())
18182 {
18183
2/2
✓ Branch 0 taken 195840 times.
✓ Branch 1 taken 3 times.
195843 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18184
1/2
✓ Branch 0 taken 195840 times.
✗ Branch 1 not taken.
195840 if(combobuf[tmpcounter].type == cLADDERONLY)
18185 combobuf[tmpcounter].type = cLADDERHOOKSHOT;
18186 3 }
18187
18188
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 3 times.
79 if(section_version<7)
18189 {
18190
2/2
✓ Branch 0 taken 195840 times.
✓ Branch 1 taken 3 times.
195843 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18191 {
18192
2/9
✓ Branch 0 taken 195837 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
195840 switch(combobuf[tmpcounter].type)
18193 {
18194 case cSLASH:
18195 3 combobuf[tmpcounter].type=cSLASHTOUCHY;
18196 3 break;
18197
18198 case cSLASHITEM:
18199 combobuf[tmpcounter].type=cSLASHITEMTOUCHY;
18200 break;
18201
18202 case cBUSH:
18203 combobuf[tmpcounter].type=cBUSHTOUCHY;
18204 break;
18205
18206 case cFLOWERS:
18207 combobuf[tmpcounter].type=cFLOWERSTOUCHY;
18208 break;
18209
18210 case cTALLGRASS:
18211 combobuf[tmpcounter].type=cTALLGRASSTOUCHY;
18212 break;
18213
18214 case cSLASHNEXT:
18215 combobuf[tmpcounter].type=cSLASHNEXTTOUCHY;
18216 break;
18217
18218 case cSLASHNEXTITEM:
18219 combobuf[tmpcounter].type=cSLASHNEXTITEMTOUCHY;
18220 break;
18221
18222 case cBUSHNEXT:
18223 combobuf[tmpcounter].type=cBUSHNEXTTOUCHY;
18224 break;
18225 }
18226 195840 }
18227 3 }
18228
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 77 times.
79 if (section_version < 16)
18229 {
18230
2/2
✓ Branch 0 taken 5026560 times.
✓ Branch 1 taken 77 times.
5026637 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18231 {
18232
2/2
✓ Branch 0 taken 5022039 times.
✓ Branch 1 taken 4521 times.
5026560 if (combobuf[tmpcounter].type == cWATER)
18233 {
18234 4521 combobuf[tmpcounter].attributes[0] = 40000L;
18235 4521 }
18236 5026560 }
18237 77 }
18238
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 1 times.
79 if(!get_bit(quest_rules,qr_ALLOW_EDITING_COMBO_0))
18239 {
18240 1 combobuf[0].walk = 0xF0;
18241 1 combobuf[0].type = 0;
18242 1 combobuf[0].flag = 0;
18243 1 }
18244 79 }
18245
18246 //Now for the new combo alias reset
18247
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
79 if(section_version<2 && keepdata)
18248 {
18249
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 3 times.
24579 for(int32_t j=0; j<MAXCOMBOALIASES; j++)
18250 {
18251 24576 combo_aliases[j].width = 0;
18252 24576 combo_aliases[j].height = 0;
18253 24576 combo_aliases[j].layermask = 0;
18254
18255
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24576 times.
24576 if(combo_aliases[j].combos != NULL)
18256 {
18257
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24576 times.
24576 delete[] combo_aliases[j].combos;
18258 24576 }
18259
18260
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24576 times.
24576 if(combo_aliases[j].csets != NULL)
18261 {
18262
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24576 times.
24576 delete[] combo_aliases[j].csets;
18263 24576 }
18264
18265 24576 combo_aliases[j].combos = new word[1];
18266 24576 combo_aliases[j].csets = new byte[1];
18267 24576 combo_aliases[j].combos[0] = 0;
18268 24576 combo_aliases[j].csets[0] = 0;
18269 24576 }
18270 3 }
18271
18272
18273 79 setup_combo_animations();
18274 79 setup_combo_animations2();
18275 79 return 0;
18276 79 }
18277 131498 int32_t readcombo_loop(PACKFILE* f, word s_version, newcombo& temp_combo)
18278 {
18279 byte combo_has_flags;
18280
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131498 times.
131498 if(!p_getc(&combo_has_flags,f,true))
18281 return qe_invalid;
18282
18283 131498 temp_combo.clear();
18284
2/2
✓ Branch 0 taken 84766 times.
✓ Branch 1 taken 46732 times.
131498 if(combo_has_flags)
18285 {
18286
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 46729 times.
46732 if(combo_has_flags&CHAS_GENERAL)
18287 {
18288
1/2
✓ Branch 0 taken 46729 times.
✗ Branch 1 not taken.
46729 if(!p_igetl(&temp_combo.tile,f,true))
18289 {
18290 return qe_invalid;
18291 }
18292 46729 temp_combo.o_tile = temp_combo.tile;
18293
18294
1/2
✓ Branch 0 taken 46729 times.
✗ Branch 1 not taken.
46729 if(!p_getc(&temp_combo.flip,f,true))
18295 {
18296 return qe_invalid;
18297 }
18298
18299
1/2
✓ Branch 0 taken 46729 times.
✗ Branch 1 not taken.
46729 if(!p_getc(&temp_combo.walk,f,true))
18300 {
18301 return qe_invalid;
18302 }
18303
18304
1/2
✓ Branch 0 taken 46729 times.
✗ Branch 1 not taken.
46729 if(!p_getc(&temp_combo.type,f,true))
18305 {
18306 return qe_invalid;
18307 }
18308
18309
1/2
✓ Branch 0 taken 46729 times.
✗ Branch 1 not taken.
46729 if(!p_getc(&temp_combo.flag,f,true))
18310 {
18311 return qe_invalid;
18312 }
18313
18314
1/2
✓ Branch 0 taken 46729 times.
✗ Branch 1 not taken.
46729 if(!p_getc(&temp_combo.csets,f,true))
18315 {
18316 return qe_invalid;
18317 }
18318 46729 }
18319
2/2
✓ Branch 0 taken 46716 times.
✓ Branch 1 taken 16 times.
46732 if(combo_has_flags&CHAS_SCRIPT)
18320 {
18321
2/2
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 16 times.
192 for ( int32_t q = 0; q < 11; q++ )
18322 {
18323
1/2
✓ Branch 0 taken 176 times.
✗ Branch 1 not taken.
176 if(!p_getc(&temp_combo.label[q],f,true))
18324 {
18325 return qe_invalid;
18326 }
18327 176 }
18328
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetw(&temp_combo.script,f,true)) return qe_invalid;
18329
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 16 times.
48 for ( int32_t q = 0; q < 2; q++ )
18330 {
18331
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(!p_igetl(&temp_combo.initd[q],f,true))
18332 {
18333 return qe_invalid;
18334 }
18335 32 }
18336 16 }
18337
2/2
✓ Branch 0 taken 33663 times.
✓ Branch 1 taken 13069 times.
46732 if(combo_has_flags&CHAS_ANIM)
18338 {
18339
1/2
✓ Branch 0 taken 13069 times.
✗ Branch 1 not taken.
13069 if(!p_getc(&temp_combo.frames,f,true))
18340 {
18341 return qe_invalid;
18342 }
18343
18344
1/2
✓ Branch 0 taken 13069 times.
✗ Branch 1 not taken.
13069 if(!p_getc(&temp_combo.speed,f,true))
18345 {
18346 return qe_invalid;
18347 }
18348
18349
1/2
✓ Branch 0 taken 13069 times.
✗ Branch 1 not taken.
13069 if(!p_igetw(&temp_combo.nextcombo,f,true))
18350 {
18351 return qe_invalid;
18352 }
18353
18354
1/2
✓ Branch 0 taken 13069 times.
✗ Branch 1 not taken.
13069 if(!p_getc(&temp_combo.nextcset,f,true))
18355 {
18356 return qe_invalid;
18357 }
18358
18359
1/2
✓ Branch 0 taken 13069 times.
✗ Branch 1 not taken.
13069 if(!p_getc(&temp_combo.skipanim,f,true))
18360 {
18361 return qe_invalid;
18362 }
18363
18364
1/2
✓ Branch 0 taken 13069 times.
✗ Branch 1 not taken.
13069 if(!p_getc(&temp_combo.skipanimy,f,true))
18365 {
18366 return qe_invalid;
18367 }
18368
18369
1/2
✓ Branch 0 taken 13069 times.
✗ Branch 1 not taken.
13069 if(!p_getc(&temp_combo.animflags,f,true))
18370 {
18371 return qe_invalid;
18372 }
18373 13069 }
18374
2/2
✓ Branch 0 taken 42653 times.
✓ Branch 1 taken 4079 times.
46732 if(combo_has_flags&CHAS_ATTRIB)
18375 {
18376
2/2
✓ Branch 0 taken 16316 times.
✓ Branch 1 taken 4079 times.
20395 for ( int32_t q = 0; q < 4; q++ )
18377 {
18378
1/2
✓ Branch 0 taken 16316 times.
✗ Branch 1 not taken.
16316 if(!p_igetl(&temp_combo.attributes[q],f,true))
18379 {
18380 return qe_invalid;
18381 }
18382 16316 }
18383
2/2
✓ Branch 0 taken 32632 times.
✓ Branch 1 taken 4079 times.
36711 for ( int32_t q = 0; q < 8; q++ )
18384 {
18385
1/2
✓ Branch 0 taken 32632 times.
✗ Branch 1 not taken.
32632 if(!p_getc(&temp_combo.attribytes[q],f,true))
18386 {
18387 return qe_invalid;
18388 }
18389 32632 }
18390
2/2
✓ Branch 0 taken 32632 times.
✓ Branch 1 taken 4079 times.
36711 for ( int32_t q = 0; q < 8; q++ )
18391 {
18392
1/2
✓ Branch 0 taken 32632 times.
✗ Branch 1 not taken.
32632 if(!p_igetw(&temp_combo.attrishorts[q],f,true))
18393 {
18394 return qe_invalid;
18395 }
18396 32632 }
18397 4079 }
18398
2/2
✓ Branch 0 taken 45433 times.
✓ Branch 1 taken 1299 times.
46732 if(combo_has_flags&CHAS_FLAG)
18399 {
18400
1/2
✓ Branch 0 taken 1299 times.
✗ Branch 1 not taken.
1299 if(!p_igetl(&temp_combo.usrflags,f,true))
18401 {
18402 return qe_invalid;
18403 }
18404
1/2
✓ Branch 0 taken 1299 times.
✗ Branch 1 not taken.
1299 if(!p_igetw(&temp_combo.genflags,f,true))
18405 {
18406 return qe_invalid;
18407 }
18408 1299 }
18409
2/2
✓ Branch 0 taken 46405 times.
✓ Branch 1 taken 327 times.
46732 if(combo_has_flags&CHAS_TRIG)
18410 {
18411
2/2
✓ Branch 0 taken 981 times.
✓ Branch 1 taken 327 times.
1308 for ( int32_t q = 0; q < 3; q++ )
18412 {
18413
1/2
✓ Branch 0 taken 981 times.
✗ Branch 1 not taken.
981 if(!p_igetl(&temp_combo.triggerflags[q],f,true))
18414 {
18415 return qe_invalid;
18416 }
18417 981 }
18418
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 if(!p_igetl(&temp_combo.triggerlevel,f,true))
18419 {
18420 return qe_invalid;
18421 }
18422
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 if(!p_getc(&temp_combo.triggerbtn,f,true))
18423 {
18424 return qe_invalid;
18425 }
18426
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 if(!p_getc(&temp_combo.triggeritem,f,true))
18427 {
18428 return qe_invalid;
18429 }
18430
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 if(!p_getc(&temp_combo.trigtimer,f,true))
18431 {
18432 return qe_invalid;
18433 }
18434
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 if(!p_getc(&temp_combo.trigsfx,f,true))
18435 {
18436 return qe_invalid;
18437 }
18438
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 if(!p_igetl(&temp_combo.trigchange,f,true))
18439 {
18440 return qe_invalid;
18441 }
18442
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 if(!p_igetw(&temp_combo.trigprox,f,true))
18443 {
18444 return qe_invalid;
18445 }
18446
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 if(!p_getc(&temp_combo.trigctr,f,true))
18447 {
18448 return qe_invalid;
18449 }
18450
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 if(!p_igetl(&temp_combo.trigctramnt,f,true))
18451 {
18452 return qe_invalid;
18453 }
18454
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 if(!p_getc(&temp_combo.triglbeam,f,true))
18455 {
18456 return qe_invalid;
18457 }
18458
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 if(!p_getc(&temp_combo.trigcschange,f,true))
18459 {
18460 return qe_invalid;
18461 }
18462
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 if(!p_igetw(&temp_combo.spawnitem,f,true))
18463 {
18464 return qe_invalid;
18465 }
18466
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 if(!p_igetw(&temp_combo.spawnenemy,f,true))
18467 {
18468 return qe_invalid;
18469 }
18470
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 if(!p_getc(&temp_combo.exstate,f,true))
18471 {
18472 return qe_invalid;
18473 }
18474
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 if(!p_igetl(&temp_combo.spawnip,f,true))
18475 {
18476 return qe_invalid;
18477 }
18478
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 if(!p_getc(&temp_combo.trigcopycat,f,true))
18479 {
18480 return qe_invalid;
18481 }
18482
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 if(!p_getc(&temp_combo.trigcooldown,f,true))
18483 {
18484 return qe_invalid;
18485 }
18486
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 327 times.
327 if(s_version >= 35)
18487 {
18488
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 if(!p_igetw(&temp_combo.prompt_cid,f,true))
18489 {
18490 return qe_invalid;
18491 }
18492
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 if(!p_getc(&temp_combo.prompt_cs,f,true))
18493 {
18494 return qe_invalid;
18495 }
18496
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 if(!p_igetw(&temp_combo.prompt_x,f,true))
18497 {
18498 return qe_invalid;
18499 }
18500
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 327 times.
327 if(!p_igetw(&temp_combo.prompt_y,f,true))
18501 {
18502 return qe_invalid;
18503 }
18504 327 }
18505 327 }
18506
2/2
✓ Branch 0 taken 46657 times.
✓ Branch 1 taken 75 times.
46732 if(combo_has_flags&CHAS_LIFT)
18507 {
18508
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_igetw(&temp_combo.liftcmb,f,true))
18509 return qe_invalid;
18510
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_getc(&temp_combo.liftcs,f,true))
18511 return qe_invalid;
18512
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_igetw(&temp_combo.liftundercmb,f,true))
18513 return qe_invalid;
18514
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_getc(&temp_combo.liftundercs,f,true))
18515 return qe_invalid;
18516
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_getc(&temp_combo.liftdmg,f,true))
18517 return qe_invalid;
18518
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_getc(&temp_combo.liftlvl,f,true))
18519 return qe_invalid;
18520
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_getc(&temp_combo.liftitm,f,true))
18521 return qe_invalid;
18522
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_getc(&temp_combo.liftflags,f,true))
18523 return qe_invalid;
18524
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_getc(&temp_combo.liftgfx,f,true))
18525 return qe_invalid;
18526
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_getc(&temp_combo.liftsprite,f,true))
18527 return qe_invalid;
18528
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_getc(&temp_combo.liftsfx,f,true))
18529 return qe_invalid;
18530
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_igetw(&temp_combo.liftbreaksprite,f,true))
18531 return qe_invalid;
18532
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_getc(&temp_combo.liftbreaksfx,f,true))
18533 return qe_invalid;
18534
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 if(s_version >= 34)
18535 {
18536
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_getc(&temp_combo.lifthei,f,true))
18537 return qe_invalid;
18538
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_getc(&temp_combo.lifttime,f,true))
18539 return qe_invalid;
18540 75 }
18541 75 }
18542 46732 }
18543 131498 return 0;
18544 131498 }
18545 99 int32_t readcombos(PACKFILE *f, zquestheader *Header, word version, word build, word start_combo, word max_combos, bool keepdata)
18546 {
18547 99 word section_version=0;
18548 99 word section_cversion=0;
18549 99 word combos_used=0;
18550 int32_t dummy;
18551 byte padding;
18552 99 newcombo temp_combo;
18553
18554 99 reset_combo_animations();
18555 99 reset_combo_animations2();
18556 99 init_combo_classes();
18557
18558
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata==true) //reset combos
18559 {
18560
2/2
✓ Branch 0 taken 6462720 times.
✓ Branch 1 taken 99 times.
6462819 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
18561 6462720 combobuf[q].clear();
18562 99 }
18563
18564
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(version > 0x192) //Version info
18565 {
18566
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&section_version,f,true))
18567 {
18568 return qe_invalid;
18569 }
18570 99 FFCore.quest_format[vCombos] = section_version;
18571
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&section_cversion,f,true))
18572 {
18573 return qe_invalid;
18574 }
18575
18576 //section size
18577
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetl(&dummy,f,true))
18578 {
18579 return qe_invalid;
18580 }
18581 99 }
18582
18583
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 79 times.
99 if(section_version > 32) //Cleanup time!
18584 {
18585
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 if(!p_igetw(&combos_used,f,true))
18586 {
18587 return qe_invalid;
18588 }
18589
2/2
✓ Branch 0 taken 131498 times.
✓ Branch 1 taken 20 times.
131518 for(int32_t i=0; i<combos_used; i++)
18590 {
18591 131498 auto ret = readcombo_loop(f,section_version,temp_combo);
18592
1/2
✓ Branch 0 taken 131498 times.
✗ Branch 1 not taken.
131498 if(ret) return ret;
18593
2/4
✓ Branch 0 taken 131498 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 131498 times.
131498 if(keepdata==true && i>=start_combo)
18594 131498 memcpy(&combobuf[i], &temp_combo, sizeof(temp_combo));
18595 131498 }
18596 20 }
18597 else //Call the old function for all old versions
18598 {
18599 79 auto ret = readcombos_old(section_version,f,Header,version,build,start_combo,max_combos,keepdata);
18600
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
79 if(ret) return ret; //error, end read
18601 }
18602
18603
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(keepdata && false/*section_version < 34*/)
18604 {
18605 for(int32_t i=start_combo; i<combos_used; i++)
18606 {
18607 newcombo& cmb = combobuf[i];
18608 //Do anything to 'cmb' needed for version handling
18609 }
18610 }
18611
18612
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata==true)
18613 {
18614
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 79 times.
99 if(!get_bit(quest_rules,qr_ALLOW_EDITING_COMBO_0))
18615 {
18616 20 combobuf[0].walk = 0xF0;
18617 20 combobuf[0].type = 0;
18618 20 combobuf[0].flag = 0;
18619 20 }
18620 99 }
18621
18622 99 setup_combo_animations();
18623 99 setup_combo_animations2();
18624 99 return 0;
18625 99 }
18626
18627 96 int32_t readcomboaliases(PACKFILE *f, zquestheader *Header, word version, word build, bool keepdata)
18628 {
18629 //these are here to bypass compiler warnings about unused arguments
18630 96 Header=Header;
18631 96 version=version;
18632 96 build=build;
18633
18634 int32_t dummy;
18635 96 word sversion=0, c_sversion;
18636
18637 //section version info
18638
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_igetw(&sversion,f,true))
18639 {
18640 return qe_invalid;
18641 }
18642
18643 96 FFCore.quest_format[vComboAliases] = sversion;
18644
18645 //al_trace("Combo aliases version %d\n", sversion);
18646
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetw(&c_sversion,f,true))
18647 {
18648 return qe_invalid;
18649 }
18650
18651 //section size
18652
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&dummy,f,true))
18653 {
18654 return qe_invalid;
18655 }
18656
18657 96 int32_t max_num_combo_aliases = MAXCOMBOALIASES;
18658
18659
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 74 times.
96 if(sversion < 3) // max saved combo alias' upped from 256 to 2048.
18660 {
18661 74 max_num_combo_aliases = MAX250COMBOALIASES;
18662 74 }
18663
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(sversion < 2) // max saved combo alias' upped from 256 to 2048.
18664 {
18665 max_num_combo_aliases = OLDMAXCOMBOALIASES;
18666 }
18667
18668
2/2
✓ Branch 0 taken 331776 times.
✓ Branch 1 taken 96 times.
331872 for(int32_t j=0; j<max_num_combo_aliases; j++)
18669 {
18670 byte width,height,mask,tempcset;
18671 int32_t count;
18672 word tempword;
18673 byte tempbyte;
18674
18675
1/2
✓ Branch 0 taken 331776 times.
✗ Branch 1 not taken.
331776 if(!p_igetw(&tempword,f,true))
18676 {
18677 return qe_invalid;
18678 }
18679
18680
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 331776 times.
331776 if(keepdata)
18681 {
18682 331776 combo_aliases[j].combo = tempword;
18683 331776 }
18684
18685
1/2
✓ Branch 0 taken 331776 times.
✗ Branch 1 not taken.
331776 if(!p_getc(&tempbyte,f,true))
18686 {
18687 return qe_invalid;
18688 }
18689
18690
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 331776 times.
331776 if(keepdata)
18691 {
18692 331776 combo_aliases[j].cset = tempbyte;
18693 331776 }
18694
18695
1/2
✓ Branch 0 taken 331776 times.
✗ Branch 1 not taken.
331776 if(!p_getc(&width,f,true))
18696 {
18697 return qe_invalid;
18698 }
18699
18700
1/2
✓ Branch 0 taken 331776 times.
✗ Branch 1 not taken.
331776 if(!p_getc(&height,f,true))
18701 {
18702 return qe_invalid;
18703 }
18704
18705
1/2
✓ Branch 0 taken 331776 times.
✗ Branch 1 not taken.
331776 if(!p_getc(&mask,f,true))
18706 {
18707 return qe_invalid;
18708 }
18709
18710 331776 count=(width+1)*(height+1)*(comboa_lmasktotal(mask)+1);
18711
18712
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 331776 times.
331776 if(keepdata)
18713 {
18714
1/2
✓ Branch 0 taken 331776 times.
✗ Branch 1 not taken.
331776 if(combo_aliases[j].combos != NULL)
18715 {
18716
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 331776 times.
331776 delete[] combo_aliases[j].combos;
18717 331776 }
18718
18719
1/2
✓ Branch 0 taken 331776 times.
✗ Branch 1 not taken.
331776 if(combo_aliases[j].csets != NULL)
18720 {
18721
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 331776 times.
331776 delete[] combo_aliases[j].csets;
18722 331776 }
18723
18724 331776 combo_aliases[j].width = width;
18725 331776 combo_aliases[j].height = height;
18726 331776 combo_aliases[j].layermask = mask;
18727 331776 combo_aliases[j].combos = new word[count];
18728 331776 combo_aliases[j].csets = new byte[count];
18729 331776 }
18730
18731
2/2
✓ Branch 0 taken 339765 times.
✓ Branch 1 taken 331776 times.
671541 for(int32_t k=0; k<count; k++)
18732 {
18733
1/2
✓ Branch 0 taken 339765 times.
✗ Branch 1 not taken.
339765 if(!p_igetw(&tempword,f,true))
18734 {
18735 return qe_invalid;
18736 }
18737
18738
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 339765 times.
339765 if(keepdata)
18739 {
18740 339765 combo_aliases[j].combos[k] = tempword;
18741 339765 }
18742 339765 }
18743
18744
2/2
✓ Branch 0 taken 339765 times.
✓ Branch 1 taken 331776 times.
671541 for(int32_t k=0; k<count; k++)
18745 {
18746
1/2
✓ Branch 0 taken 339765 times.
✗ Branch 1 not taken.
339765 if(!p_getc(&tempcset,f,true))
18747 {
18748 return qe_invalid;
18749 }
18750
18751
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 339765 times.
339765 if(keepdata)
18752 {
18753 339765 combo_aliases[j].csets[k] = tempcset;
18754 339765 }
18755 339765 }
18756 331776 }
18757
18758 96 word num_combo_pools = 0;
18759
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 20 times.
96 if(sversion >= 4)
18760 {
18761
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 if(!p_igetw(&num_combo_pools,f,true))
18762 {
18763 return qe_invalid;
18764 }
18765 20 }
18766
18767
2/2
✓ Branch 0 taken 786432 times.
✓ Branch 1 taken 96 times.
786528 for(combo_pool& pool : combo_pools)
18768 {
18769 786432 pool.clear();
18770 }
18771
18772 96 combo_pool temp_cpool;
18773
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 96 times.
150 for(word cp = 0; cp < num_combo_pools; ++cp)
18774 {
18775 54 int32_t num_combos_in_pool = 0;
18776
2/4
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 54 times.
✗ Branch 3 not taken.
54 if(!p_igetl(&num_combos_in_pool,f,true))
18777 {
18778 return qe_invalid;
18779 }
18780
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 if(num_combos_in_pool < 1) continue; //nothing to read
18781
18782
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 temp_cpool.clear();
18783
18784 int32_t cp_cid; int8_t cp_cs; word cp_quant;
18785
2/2
✓ Branch 0 taken 234 times.
✓ Branch 1 taken 54 times.
288 for(auto q = 0; q < num_combos_in_pool; ++q)
18786 {
18787
2/4
✓ Branch 0 taken 234 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 234 times.
✗ Branch 3 not taken.
234 if(!p_igetl(&cp_cid,f,true))
18788 {
18789 return qe_invalid;
18790 }
18791
2/4
✓ Branch 0 taken 234 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 234 times.
✗ Branch 3 not taken.
234 if(!p_getc(&cp_cs,f,true))
18792 {
18793 return qe_invalid;
18794 }
18795
2/4
✓ Branch 0 taken 234 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 234 times.
✗ Branch 3 not taken.
234 if(!p_igetw(&cp_quant,f,true))
18796 {
18797 return qe_invalid;
18798 }
18799
1/2
✓ Branch 0 taken 234 times.
✗ Branch 1 not taken.
234 temp_cpool.add(cp_cid, cp_cs, cp_quant);
18800 234 }
18801
18802
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 if(keepdata)
18803 {
18804
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 combo_pools[cp] = temp_cpool;
18805 54 }
18806 54 }
18807
18808 96 return 0;
18809 96 }
18810
18811 99 int32_t readcolordata(PACKFILE *f, miscQdata *Misc, word version, word build, word start_cset, word max_csets, bool keepdata)
18812 {
18813 //these are here to bypass compiler warnings about unused arguments
18814
18815 //THE *48 REFERS TO EACH CSET BEING 16 COLORS with 3 VALUES OF RGB (3*16 is 48)
18816 //Capitalized cause it'll save you a headache. -Deedee
18817 99 start_cset=start_cset;
18818 99 max_csets=max_csets;
18819 99 word s_version=0;
18820
18821 miscQdata temp_misc;
18822 99 memcpy(&temp_misc, Misc, sizeof(temp_misc));
18823
18824 byte temp_colordata[48];
18825 char temp_palname[PALNAMESIZE];
18826
18827 int32_t dummy;
18828 word palcycles;
18829
18830
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(version > 0x192)
18831 {
18832 //section version info
18833
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&s_version,f,true))
18834 {
18835 return qe_invalid;
18836 }
18837
18838 99 FFCore.quest_format[vCSets] = s_version;
18839
18840 //al_trace("Color data version %d\n", s_version);
18841
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&dummy,f,true))
18842 {
18843 return qe_invalid;
18844 }
18845
18846 //section size
18847
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetl(&dummy,f,true))
18848 {
18849 return qe_invalid;
18850 }
18851 99 }
18852
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 22 times.
99 if (s_version < 5)
18853 {
18854
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
77 bool RealOldVerion = ((version < 0x192)||((version == 0x192)&&(build<73)));
18855
18856 //finally... section data
18857 77 int32_t q = 0;
18858 77 int32_t p = -15;
18859
2/2
✓ Branch 0 taken 18480 times.
✓ Branch 1 taken 77 times.
18557 for(int32_t i=0; i<oldpdTOTAL; ++i)
18860 {
18861 18480 memset(temp_colordata, 0, 48);
18862
18863
1/2
✓ Branch 0 taken 18480 times.
✗ Branch 1 not taken.
18480 if(!pfread(temp_colordata,48,f,true))
18864 {
18865 return qe_invalid;
18866 }
18867
18868
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18480 times.
18480 if(keepdata==true)
18869 {
18870 18480 memcpy(&colordata[q*48], temp_colordata, 48);
18871 18480 }
18872 18480 ++q;
18873
7/8
✓ Branch 0 taken 17248 times.
✓ Branch 1 taken 1232 times.
✓ Branch 2 taken 1309 times.
✓ Branch 3 taken 15939 times.
✓ Branch 4 taken 154 times.
✓ Branch 5 taken 1155 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 154 times.
18480 if (p > 0 && (p%13)==12 && (i < oldpoSPRITE || !RealOldVerion)) //It's > 0 instead of >= 0 because it should append
18874 {
18875
1/2
✓ Branch 0 taken 1309 times.
✗ Branch 1 not taken.
1309 if (s_version < 5) //Bumping up the size of level palettes
18876 {
18877
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1309 times.
1309 if(keepdata==true)
18878 {
18879 1309 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18880 1309 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18881 1309 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18882 1309 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18883 1309 }
18884 1309 q+=4;
18885 1309 }
18886 else
18887 {
18888 for(int m = 0; m < 4; ++m)
18889 {
18890 memset(temp_colordata, 0, 48);
18891 if(!pfread(temp_colordata,48,f,true))
18892 {
18893 return qe_invalid;
18894 }
18895 if(keepdata==true)
18896 {
18897 memcpy(&colordata[q*48], temp_colordata, 48);
18898 }
18899 ++q;
18900 }
18901 }
18902 1309 }
18903 18480 ++p;
18904 18480 }
18905
18906
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(RealOldVerion)
18907 {
18908 if(keepdata==true)
18909 {
18910 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
18911 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
18912 memcpy(colordata+((poSPRITE255+11)*48), colordata+((poSPRITE255+10)*48), 48);
18913 memcpy(colordata+((poSPRITE255+10)*48), colordata+((poSPRITE255+9)*48), 48);
18914 memcpy(colordata+((poSPRITE255+9)*48), colordata+((poSPRITE255+8)*48), 48);
18915 memset(colordata+((poSPRITE255+8)*48), 0, 48);
18916 }
18917 }
18918 else
18919 {
18920 77 memset(temp_colordata, 0, 48);
18921
18922
2/2
✓ Branch 0 taken 241241 times.
✓ Branch 1 taken 77 times.
241318 for(int32_t i=0; i<newpdTOTAL-oldpdTOTAL; ++i)
18923 {
18924
1/2
✓ Branch 0 taken 241241 times.
✗ Branch 1 not taken.
241241 if(!pfread(temp_colordata,48,f,true))
18925 {
18926 return qe_invalid;
18927 }
18928
18929
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 241241 times.
241241 if(keepdata==true)
18930 {
18931 241241 memcpy(&colordata[q*48], temp_colordata, 48);
18932 241241 }
18933 241241 ++q;
18934
7/8
✓ Branch 0 taken 241241 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18557 times.
✓ Branch 3 taken 222684 times.
✓ Branch 4 taken 154 times.
✓ Branch 5 taken 18403 times.
✓ Branch 6 taken 148 times.
✓ Branch 7 taken 6 times.
241241 if (p > 0 && (p%13)==12 && (i < (newpoSPRITE-oldpdTOTAL) || (s_version >= 4))) //It's > 0 instead of >= 0 because it should append
18935 {
18936
1/2
✓ Branch 0 taken 18551 times.
✗ Branch 1 not taken.
18551 if (s_version < 5) //Bumping up the size of level palettes
18937 {
18938
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18551 times.
18551 if(keepdata==true)
18939 {
18940 18551 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18941 18551 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18942 18551 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18943 18551 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18944 18551 }
18945 18551 q+=4;
18946 18551 }
18947 else
18948 {
18949 for(int m = 0; m < 4; ++m)
18950 {
18951 memset(temp_colordata, 0, 48);
18952 if(!pfread(temp_colordata,48,f,true))
18953 {
18954 return qe_invalid;
18955 }
18956 if(keepdata==true)
18957 {
18958 memcpy(&colordata[q*48], temp_colordata, 48);
18959 }
18960 ++q;
18961 }
18962 }
18963 18551 }
18964 241241 ++p;
18965 241241 }
18966
18967
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 74 times.
77 if(s_version < 4)
18968 {
18969
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(keepdata==true)
18970 {
18971 3 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
18972 3 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
18973 3 }
18974 3 }
18975 else
18976 {
18977
2/2
✓ Branch 0 taken 246272 times.
✓ Branch 1 taken 74 times.
246346 for(int32_t i=0; i<newerpdTOTAL-newpdTOTAL; ++i)
18978 {
18979
1/2
✓ Branch 0 taken 246272 times.
✗ Branch 1 not taken.
246272 if(!pfread(temp_colordata,48,f,true))
18980 {
18981 return qe_invalid;
18982 }
18983
18984
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 246272 times.
246272 if(keepdata==true)
18985 {
18986 246272 memcpy(&colordata[q*48], temp_colordata, 48);
18987 246272 }
18988 246272 ++q;
18989
5/6
✓ Branch 0 taken 246272 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18944 times.
✓ Branch 3 taken 227328 times.
✓ Branch 4 taken 148 times.
✓ Branch 5 taken 18796 times.
246272 if (p > 0 && (p%13)==12 && i < newerpoSPRITE-newpdTOTAL) //It's > 0 instead of >= 0 because it should append
18990 {
18991
1/2
✓ Branch 0 taken 18796 times.
✗ Branch 1 not taken.
18796 if (s_version < 5) //Bumping up the size of level palettes
18992 {
18993
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18796 times.
18796 if(keepdata==true)
18994 {
18995 18796 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18996 18796 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18997 18796 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18998 18796 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18999 18796 }
19000 18796 q+=4;
19001 18796 }
19002 else
19003 {
19004 for(int m = 0; m < 4; ++m)
19005 {
19006 memset(temp_colordata, 0, 48);
19007 if(!pfread(temp_colordata,48,f,true))
19008 {
19009 return qe_invalid;
19010 }
19011 if(keepdata==true)
19012 {
19013 memcpy(&colordata[q*48], temp_colordata, 48);
19014 }
19015 ++q;
19016 }
19017 }
19018 18796 }
19019 246272 ++p;
19020 246272 }
19021
19022 //By this point, q should be about equal to pdTOTAL255. If it isn't, I've fucked up. -Deedee
19023 }
19024 }
19025 77 }
19026 else
19027 {
19028
2/2
✓ Branch 0 taken 192478 times.
✓ Branch 1 taken 22 times.
192500 for(int32_t i=0; i<pdTOTAL255; ++i)
19029 {
19030 192478 memset(temp_colordata, 0, 48);
19031
19032
1/2
✓ Branch 0 taken 192478 times.
✗ Branch 1 not taken.
192478 if(!pfread(temp_colordata,48,f,true))
19033 {
19034 return qe_invalid;
19035 }
19036
19037
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192478 times.
192478 if(keepdata==true)
19038 {
19039 192478 memcpy(&colordata[i*48], temp_colordata, 48);
19040 192478 }
19041 192478 }
19042 }
19043
19044
2/6
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if((version < 0x192)||((version == 0x192)&&(build<76)))
19045 {
19046 if(keepdata==true)
19047 {
19048 init_palnames();
19049 }
19050 }
19051 else
19052 {
19053 99 int32_t palnamestoread = 0;
19054
19055
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 96 times.
99 if(s_version < 3)
19056 3 palnamestoread = OLDMAXLEVELS;
19057 else
19058 96 palnamestoread = 512;
19059
19060
2/2
✓ Branch 0 taken 49920 times.
✓ Branch 1 taken 99 times.
50019 for(int32_t i=0; i<palnamestoread; ++i)
19061 {
19062 49920 memset(temp_palname, 0, PALNAMESIZE);
19063
19064
1/2
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
49920 if(!pfread(temp_palname,PALNAMESIZE,f,true))
19065 {
19066 return qe_invalid;
19067 }
19068
19069
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49920 times.
49920 if(keepdata==true)
19070 {
19071 49920 memcpy(palnames[i], temp_palname, PALNAMESIZE);
19072 49920 }
19073 49920 }
19074
19075
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata)
19076 {
19077
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 99 times.
867 for(int32_t i=palnamestoread; i<MAXLEVELS; i++)
19078 {
19079 768 memset(palnames[i], 0, PALNAMESIZE);
19080 768 }
19081 99 }
19082 }
19083
19084
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(version > 0x192)
19085 {
19086
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<256; i++)
19087 {
19088
2/2
✓ Branch 0 taken 76032 times.
✓ Branch 1 taken 25344 times.
101376 for(int32_t j=0; j<3; j++)
19089 {
19090 76032 temp_misc.cycles[i][j].first=0;
19091 76032 temp_misc.cycles[i][j].count=0;
19092 76032 temp_misc.cycles[i][j].speed=0;
19093 76032 }
19094 25344 }
19095
19096
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&palcycles,f,true))
19097 {
19098 return qe_invalid;
19099 }
19100
19101
2/2
✓ Branch 0 taken 3223 times.
✓ Branch 1 taken 99 times.
3322 for(int32_t i=0; i<palcycles; i++)
19102 {
19103
2/2
✓ Branch 0 taken 9669 times.
✓ Branch 1 taken 3223 times.
12892 for(int32_t j=0; j<3; j++)
19104 {
19105
1/2
✓ Branch 0 taken 9669 times.
✗ Branch 1 not taken.
9669 if(!p_getc(&temp_misc.cycles[i][j].first,f,true))
19106 {
19107 return qe_invalid;
19108 }
19109 9669 }
19110
19111
2/2
✓ Branch 0 taken 9669 times.
✓ Branch 1 taken 3223 times.
12892 for(int32_t j=0; j<3; j++)
19112 {
19113
1/2
✓ Branch 0 taken 9669 times.
✗ Branch 1 not taken.
9669 if(!p_getc(&temp_misc.cycles[i][j].count,f,true))
19114 {
19115 return qe_invalid;
19116 }
19117 9669 }
19118
19119
2/2
✓ Branch 0 taken 9669 times.
✓ Branch 1 taken 3223 times.
12892 for(int32_t j=0; j<3; j++)
19120 {
19121
1/2
✓ Branch 0 taken 9669 times.
✗ Branch 1 not taken.
9669 if(!p_getc(&temp_misc.cycles[i][j].speed,f,true))
19122 {
19123 return qe_invalid;
19124 }
19125 9669 }
19126 3223 }
19127
19128
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata==true)
19129 {
19130 99 memcpy(Misc, &temp_misc, sizeof(temp_misc));
19131 99 }
19132 99 }
19133
19134 99 return 0;
19135 99 }
19136
19137 99 int32_t readtiles(PACKFILE *f, tiledata *buf, zquestheader *Header, word version, word build, word start_tile, int32_t max_tiles, bool from_init, bool keepdata)
19138 {
19139 99 int32_t tiles_used=0;
19140 99 word section_version = 0;
19141 99 word section_cversion = 0;
19142 99 int32_t section_size= 0;
19143 99 byte *temp_tile = new byte[tilesize(tf32Bit)];
19144
19145 //Tile Expansion
19146 //if ( version >= 0x254 && build >= 41 )
19147
3/4
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 22 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 77 times.
99 if (version < 0x254 && build < 41)
19148 {
19149 //al_trace("Build was < 41 when reading tiles\n");
19150 77 max_tiles = ZC250MAXTILES;
19151 77 }
19152
19153 //al_trace("Max Tiles: %d\n", max_tiles);
19154
19155
2/6
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if(Header!=NULL&&(!Header->data_flags[ZQ_TILES]&&!from_init)) //keep for old quests
19156 {
19157 if(keepdata==true)
19158 {
19159 if(!init_tiles(true, Header))
19160 {
19161 al_trace("Unable to initialize tiles\n");
19162 }
19163 }
19164
19165 delete[] temp_tile;
19166 temp_tile=NULL;
19167 return 0;
19168 }
19169 else
19170 {
19171
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(version > 0x192)
19172 {
19173 //section version info
19174
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&section_version,f,true))
19175 {
19176 delete[] temp_tile;
19177 return qe_invalid;
19178 }
19179
19180 99 FFCore.quest_format[vTiles] = section_version;
19181
19182
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&section_cversion,f,true))
19183 {
19184 delete[] temp_tile;
19185 return qe_invalid;
19186 }
19187
19188 //section size
19189
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetl(&section_size,f,true))
19190 {
19191 delete[] temp_tile;
19192 return qe_invalid;
19193 }
19194 99 }
19195
19196 //if ( build < 41 )
19197 //{
19198 // tiles_used = ZC250MAXTILES;
19199 //}
19200
19201
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(version < 0x174)
19202 {
19203 tiles_used=TILES_PER_PAGE*4;
19204 } //no expanded tile space
19205
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 else if(version < 0x191)
19206 {
19207 tiles_used=OLDMAXTILES;
19208 }
19209 else
19210 {
19211 //finally... section data
19212
3/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 22 times.
99 if ( version >= 0x254 && build >= 41 ) //read and write the size of tiles_used properly
19213 {
19214
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(!p_igetl(&tiles_used,f,true))
19215 {
19216 delete[] temp_tile;
19217 return qe_invalid;
19218 }
19219 22 }
19220 else
19221 {
19222
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&tiles_used,f,true))
19223 {
19224 delete[] temp_tile;
19225 return qe_invalid;
19226 }
19227 }
19228 }
19229
19230
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 tiles_used=zc_min(tiles_used, max_tiles);
19231
19232 //if ( version < 0x254 || ( version >= 0x254 && build < 41 )) //don't do this, it crashes ZQuest. -Z
19233 //if ( version < 0x254 && build < 41 )
19234
3/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 22 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if ( version < 0x254 || (version == 0x254 && build < 41) )
19235 //if ( build < 41 )
19236 {
19237
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 tiles_used=zc_min(tiles_used, ZC250MAXTILES-start_tile);
19238 77 }
19239 else //2.55
19240 {
19241
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 tiles_used = zc_min(tiles_used,NEWMAXTILES-start_tile);
19242 }
19243
19244 //if ( section_version > 1 ) tiles_used = NEWMAXTILES;
19245
19246 //al_trace("tiles_used = %d\n", tiles_used);
19247
19248
2/2
✓ Branch 0 taken 2239372 times.
✓ Branch 1 taken 99 times.
2239471 for(int32_t i=0; i<tiles_used; ++i)
19249 {
19250 2239372 byte format=tf4Bit;
19251 2239372 memset(temp_tile, 0, tilesize(tf32Bit));
19252
19253
3/6
✓ Branch 0 taken 34986 times.
✓ Branch 1 taken 2204386 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34986 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2239372 if((version>0x211)||((version==0x211)&&(build>4)))
19254 {
19255
1/2
✓ Branch 0 taken 2204386 times.
✗ Branch 1 not taken.
2204386 if(!p_getc(&format,f,true))
19256 {
19257 delete[] temp_tile;
19258 return qe_invalid;
19259 }
19260 2204386 }
19261
4/4
✓ Branch 0 taken 557954 times.
✓ Branch 1 taken 1681418 times.
✓ Branch 2 taken 276608 times.
✓ Branch 3 taken 281346 times.
2239372 if(section_version > 2 && !format)
19262 {
19263
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 281346 times.
281346 if(keepdata)
19264 {
19265 281346 reset_tile(buf,start_tile+i,tf4Bit);
19266 281346 }
19267 281346 continue;
19268 }
19269
19270
1/2
✓ Branch 0 taken 1958026 times.
✗ Branch 1 not taken.
1958026 if(!pfread(temp_tile,tilesize(format),f,true))
19271 {
19272 delete[] temp_tile;
19273 return qe_invalid;
19274 }
19275
19276
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1958026 times.
1958026 if(keepdata==true)
19277 {
19278 1958026 buf[start_tile+i].format=format;
19279
19280
1/2
✓ Branch 0 taken 1958026 times.
✗ Branch 1 not taken.
1958026 if(buf[start_tile+i].data)
19281 {
19282 1958026 free(buf[start_tile+i].data);
19283 1958026 buf[start_tile+i].data=NULL;
19284 1958026 }
19285
19286 1958026 buf[start_tile+i].data=(byte *)malloc(tilesize(buf[start_tile+i].format));
19287 1958026 memcpy(buf[start_tile+i].data,temp_tile,tilesize(buf[start_tile+i].format));
19288 1958026 }
19289 1958026 }
19290 }
19291
19292
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if ( section_version < 2 ) //write blank tile data --check s_version with this again instead?
19293 {
19294 //al_trace("Writing blank tile data to new tiles for build < 41\n");
19295
2/2
✓ Branch 0 taken 11471460 times.
✓ Branch 1 taken 77 times.
11471537 for ( int32_t q = ZC250MAXTILES; q < NEWMAXTILES; ++q )
19296 {
19297
19298 //memcpy(buf[q].data,temp_tile,tilesize(buf[q].format));
19299 11471460 reset_tile(buf,q,tf4Bit);
19300
19301
19302 /*
19303
19304 byte tempbyte;
19305 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19306 {
19307 tempbyte=buf[ZC250MAXTILES-1].data[i];
19308 buf[q].data[i] = tempbyte;
19309 }
19310 //int32_t temp = tempbyte=buf[130].data[i];
19311 //buf[q].data = buf[ZC250MAXTILES-1].data;
19312 */
19313 //reset_tile(buf,q,tf4Bit);
19314 11471460 }
19315
19316 77 }
19317
19318
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata==true)
19319 {
19320
4/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
99 if ( version < 0x254 || ( version >= 0x254 && build < 41 ))
19321 {
19322
2/2
✓ Branch 0 taken 3747632 times.
✓ Branch 1 taken 77 times.
3747709 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19323 {
19324 //al_trace("Resetting tiles for ZC250MAXTILES, iteration: %d\n", i);
19325 3747632 reset_tile(buf,i,tf4Bit);
19326 3747632 }
19327 77 }
19328 else
19329 {
19330
2/2
✓ Branch 0 taken 3777036 times.
✓ Branch 1 taken 22 times.
3777058 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19331 {
19332 //al_trace("Resetting tiles for build 41+\n");
19333 3777036 reset_tile(buf,i,tf4Bit);
19334 3777036 }
19335 }
19336
19337
2/6
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if((version < 0x192)|| ((version == 0x192)&&(build<186)))
19338 {
19339 if(get_bit(quest_rules,qr_BSZELDA)) //
19340 {
19341 byte tempbyte;
19342 int32_t floattile=wpnsbuf[iwSwim].tile;
19343
19344 for(int32_t i=0; i<tilesize(tf4Bit); i++) //BSZelda tiles are out of order //does this include swim tiles?
19345 {
19346 tempbyte=buf[23].data[i];
19347 buf[23].data[i]=buf[24].data[i];
19348 buf[24].data[i]=buf[25].data[i];
19349 buf[25].data[i]=buf[26].data[i];
19350 buf[26].data[i]=tempbyte;
19351 }
19352 //swim tiles are out of order, too, but nobody cared? -Z
19353 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19354 {
19355 tempbyte=buf[floattile+11].data[i];
19356 buf[floattile+11].data[i]=buf[floattile+12].data[i];
19357 buf[floattile+12].data[i]=tempbyte;
19358 }
19359 }
19360 }
19361
19362
3/6
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 96 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if((version < 0x211)||((version == 0x211)&&(build<7))) //Goriya tiles are out of order
19363 {
19364
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!get_bit(quest_rules,qr_NEWENEMYTILES))
19365 {
19366 byte tempbyte;
19367
19368 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19369 {
19370 tempbyte=buf[130].data[i];
19371 buf[130].data[i]=buf[132].data[i];
19372 buf[132].data[i]=tempbyte;
19373
19374 tempbyte=buf[131].data[i];
19375 buf[131].data[i]=buf[133].data[i];
19376 buf[133].data[i]=tempbyte;
19377 }
19378 }
19379 3 }
19380
19381 99 al_trace("Registering blank tiles\n");
19382 99 register_blank_tiles();
19383 99 }
19384
19385 //memset(temp_tile, 0, tilesize(tf32Bit));
19386
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 delete[] temp_tile;
19387 99 temp_tile=NULL;
19388 99 return 0;
19389 99 }
19390
19391 99 int32_t readtunes(PACKFILE *f, zquestheader *Header, zctune *tunes /*zcmidi_ *midis*/, bool keepdata)
19392 {
19393 99 byte *mf=midi_flags;
19394 int32_t dummy;
19395 word dummy2;
19396 // zcmidi_ temp_midi;
19397 int32_t tunes_to_read;
19398 99 int32_t tune_count=0;
19399 99 word section_version=0;
19400 99 zctune temp;
19401
19402
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(Header->zelda_version < 0x193)
19403 {
19404 // mf=Header->data_flags+ZQ_MIDIS2;
19405 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<178)))
19406 {
19407 tunes_to_read=MAXCUSTOMMIDIS192b177;
19408 }
19409 else
19410 {
19411 tunes_to_read=MAXCUSTOMTUNES;
19412 }
19413 }
19414 else
19415 {
19416 //section version info
19417
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&section_version,f,true))
19418 {
19419 return qe_invalid;
19420 }
19421
19422 99 FFCore.quest_format[vMIDIs] = section_version;
19423
19424 //al_trace("Tunes version %d\n", section_version);
19425
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&dummy2,f,true))
19426 {
19427 return qe_invalid;
19428 }
19429
19430 //section size
19431
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetl(&dummy,f,true))
19432 {
19433 return qe_invalid;
19434 }
19435
19436 //finally... section data
19437
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!pfread(midi_flags,sizeof(midi_flags),f,true))
19438 {
19439 return qe_invalid;
19440 }
19441
19442 99 tunes_to_read=MAXCUSTOMTUNES;
19443 }
19444
19445
2/2
✓ Branch 0 taken 24948 times.
✓ Branch 1 taken 99 times.
25047 for(int32_t i=0; i<MAXCUSTOMTUNES; ++i)
19446 {
19447
2/2
✓ Branch 0 taken 23319 times.
✓ Branch 1 taken 1629 times.
24948 if(get_bit(mf, i))
19448 {
19449 1629 ++tune_count;
19450 1629 }
19451 24948 }
19452
19453
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata==true)
19454 {
19455 99 reset_tunes(tunes); //reset_midis(midis);
19456 99 }
19457
19458
2/2
✓ Branch 0 taken 24948 times.
✓ Branch 1 taken 99 times.
25047 for(int32_t i=0; i<tunes_to_read; i++)
19459 {
19460 24948 temp.clear(); //memset(&temp_midi,0,sizeof(zcmidi_));
19461
19462
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24948 times.
24948 if(keepdata==true)
19463 {
19464 24948 tunes[i].reset(); // reset_midi(midis+i);
19465 24948 }
19466
19467
2/2
✓ Branch 0 taken 23319 times.
✓ Branch 1 taken 1629 times.
24948 if(get_bit(mf,i))
19468 {
19469
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 1530 times.
1629 if(section_version < 4)
19470 {
19471
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!pfread(&temp.title,sizeof(char)*20,f,true))
19472 {
19473 return qe_invalid;
19474 }
19475 99 }
19476 else
19477 {
19478
1/2
✓ Branch 0 taken 1530 times.
✗ Branch 1 not taken.
1530 if(!pfread(&temp.title,sizeof(temp.title),f,true))
19479 {
19480 return qe_invalid;
19481 }
19482 }
19483
19484
1/2
✓ Branch 0 taken 1629 times.
✗ Branch 1 not taken.
1629 if(!p_igetl(&temp.start,f,true))
19485 {
19486 return qe_invalid;
19487 }
19488
19489
1/2
✓ Branch 0 taken 1629 times.
✗ Branch 1 not taken.
1629 if(!p_igetl(&temp.loop_start,f,true))
19490 {
19491 return qe_invalid;
19492 }
19493
19494
1/2
✓ Branch 0 taken 1629 times.
✗ Branch 1 not taken.
1629 if(!p_igetl(&temp.loop_end,f,true))
19495 {
19496 return qe_invalid;
19497 }
19498
19499
1/2
✓ Branch 0 taken 1629 times.
✗ Branch 1 not taken.
1629 if(!p_igetw(&temp.loop,f,true))
19500 {
19501 return qe_invalid;
19502 }
19503
19504
1/2
✓ Branch 0 taken 1629 times.
✗ Branch 1 not taken.
1629 if(!p_igetw(&temp.volume,f,true))
19505 {
19506 return qe_invalid;
19507 }
19508
19509
1/2
✓ Branch 0 taken 1629 times.
✗ Branch 1 not taken.
1629 if(Header->zelda_version < 0x193)
19510 {
19511 if(!p_igetl(&dummy,f,true))
19512 {
19513 return qe_invalid;
19514 }
19515 }
19516
19517
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 1530 times.
1629 if(section_version >= 3)
19518 {
19519
1/2
✓ Branch 0 taken 1530 times.
✗ Branch 1 not taken.
1530 if(!pfread(&temp.flags,sizeof(temp.flags),f,true))
19520 {
19521 return qe_invalid;
19522 }
19523 1530 }
19524
19525
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1629 times.
1629 if(keepdata==true)
19526 {
19527 1629 tunes[i].copyfrom(temp); // memcpy(&midis[i], &temp_midi, sizeof(zcmidi_));
19528 1629 }
19529
19530
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 1530 times.
1629 if(section_version < 2) //= 1 || (Header->zelda_version < 0x211) || (Header->zelda_version == 0x211 && Header->build < 18))
19531 {
19532 // old format - a midi is a midi
19533
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(((keepdata==true?tunes[i].data:temp.data)=read_midi(f, true))==NULL)
19534 {
19535 return qe_invalid;
19536 }
19537
19538 //yes you can do this. Isn't the ? operator awesome? :)
19539
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 (keepdata ? tunes[i] : temp).format = MFORMAT_MIDI;
19540 99 }
19541 else
19542 {
19543 // 'midi' could be midi or nes, gb, ... music
19544
2/4
✓ Branch 0 taken 1530 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1530 times.
✗ Branch 3 not taken.
1530 if(!pfread(&(keepdata ? tunes[i] : temp).format,sizeof((keepdata ? tunes[i] : temp).format),f,true))
19545 {
19546 return qe_invalid;
19547 }
19548
19549
1/2
✓ Branch 0 taken 1530 times.
✗ Branch 1 not taken.
1530 zctune *ptr = (keepdata==true)?&(tunes[i]):&temp;
19550
19551
1/2
✓ Branch 0 taken 1530 times.
✗ Branch 1 not taken.
1530 switch(temp.format)
19552 {
19553 case MFORMAT_MIDI:
19554
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1530 times.
1530 if((ptr->data=read_midi(f, true))==NULL)
19555 {
19556 return qe_invalid;
19557 }
19558
19559 1530 break;
19560
19561 default:
19562 return qe_invalid;
19563 break;
19564 }
19565 }
19566 1629 }
19567 24948 }
19568
19569 99 return 0;
19570 99 }
19571
19572 99 int32_t readcheatcodes(PACKFILE *f, zquestheader *Header, bool keepdata)
19573 {
19574 int32_t dummy;
19575 ZCHEATS tempzcheats;
19576 99 char temp_use_cheats=1;
19577 99 memset(&tempzcheats, 0, sizeof(tempzcheats));
19578 99 word s_version = 0;
19579
19580
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(Header->zelda_version > 0x192)
19581 {
19582 //section version info
19583
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&s_version,f,true))
19584 {
19585 return qe_invalid;
19586 }
19587
19588 99 FFCore.quest_format[vCheats] = s_version;
19589 //al_trace("Cheats version %d\n", dummy);
19590
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&dummy,f,true))
19591 {
19592 return qe_invalid;
19593 }
19594
19595 //section size
19596
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetl(&dummy,f,true))
19597 {
19598 return qe_invalid;
19599 }
19600
19601 //finally... section data
19602
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(!p_getc(&temp_use_cheats,f,true))
19603 {
19604 return qe_invalid;
19605 }
19606 99 }
19607
19608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(Header->data_flags[ZQ_CHEATS2])
19609 {
19610
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetl(&tempzcheats.flags,f,true))
19611 {
19612 return qe_invalid;
19613 }
19614
19615
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!pfread(&tempzcheats.codes, sizeof(tempzcheats.codes), f,true))
19616 {
19617 return qe_invalid;
19618 }
19619 99 }
19620
19621
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata==true)
19622 {
19623 99 memcpy(&zcheats, &tempzcheats, sizeof(tempzcheats));
19624 99 Header->data_flags[ZQ_CHEATS2]=temp_use_cheats;
19625 99 }
19626
19627 99 return 0;
19628 99 }
19629
19630 253 int32_t readinitdata(PACKFILE *f, zquestheader *Header, bool keepdata)
19631 {
19632 int32_t dummy;
19633 253 word s_version=0, s_cversion=0;
19634 byte padding;
19635 word tempw;
19636
19637 253 zinitdata temp_zinit;
19638
19639 // Legacy item properties (now integrated into itemdata)
19640 byte sword_hearts[4];
19641 byte beam_hearts[4];
19642 253 byte beam_percent=0;
19643 word beam_power[4];
19644 253 byte hookshot_length=99;
19645 253 byte hookshot_links=100;
19646 253 byte longshot_length=99;
19647 253 byte longshot_links=100;
19648 253 byte moving_fairy_hearts=3;
19649 253 byte moving_fairy_heart_percent=0;
19650 253 byte stationary_fairy_hearts=3;
19651 253 byte stationary_fairy_heart_percent=0;
19652 253 byte moving_fairy_magic=0;
19653 253 byte moving_fairy_magic_percent=0;
19654 253 byte stationary_fairy_magic=0;
19655 253 byte stationary_fairy_magic_percent=0;
19656 253 byte blue_potion_hearts=100;
19657 253 byte blue_potion_heart_percent=1;
19658 253 byte red_potion_hearts=100;
19659 253 byte red_potion_heart_percent=1;
19660 253 byte blue_potion_magic=100;
19661 253 byte blue_potion_magic_percent=1;
19662 253 byte red_potion_magic=100;
19663 253 byte red_potion_magic_percent=1;
19664
19665
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 154 times.
253 temp_zinit.subscreen_style=get_bit(quest_rules,qr_COOLSCROLL)?1:0;
19666
19667
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(Header->zelda_version > 0x192)
19668 {
19669 //section version info
19670
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_igetw(&s_version,f,true))
19671 {
19672 return qe_invalid;
19673 }
19674
19675 99 FFCore.quest_format[vInitData] = s_version;
19676
19677 //al_trace("Init data version %d\n", s_version);
19678
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_igetw(&s_cversion,f,true))
19679 {
19680 return qe_invalid;
19681 }
19682
19683 //section size
19684
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_igetl(&dummy,f,true))
19685 {
19686 return qe_invalid;
19687 }
19688 99 }
19689
19690 /* HIGHLY UNORTHODOX UPDATING THING, by L
19691 * This fixes quests made before revision 277 (such as the 'Lost Isle Build'),
19692 * where the speed of Pols Voice changed. It also coincided with V_INITDATA
19693 * changing from 13 to 14.
19694 */
19695
3/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✓ Branch 3 taken 3 times.
99 if(keepdata && s_version < 14)
19696 3 fixpolsvoice=true;
19697
19698 /* End highly unorthodox updating thing */
19699
19700
5/6
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 73 times.
✓ Branch 5 taken 23 times.
99 if(s_version >= 15 && get_bit(deprecated_rules, 27)) // The int16_t-lived rule, qr_JUMPHEROLAYER3
19701 23 temp_zinit.jump_hero_layer_threshold=0;
19702
19703
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 96 times.
99 if(s_version >= 10)
19704 {
19705 char temp;
19706
19707 //new-style items
19708
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 96 times.
24672 for(int32_t j=0; j<256; j++)
19709 {
19710
2/4
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24576 times.
24576 if(!p_getc(&temp,f,true))
19711 return qe_invalid;
19712
19713 24576 temp_zinit.items[j] = (temp != 0);
19714 24576 }
19715 96 }
19716
19717
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 55 times.
✓ Branch 5 taken 55 times.
99 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>26)))
19718 {
19719 char temp;
19720
19721 //finally... section data
19722
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
✓ Branch 2 taken 55 times.
✓ Branch 3 taken 55 times.
154 if((Header->zelda_version > 0x192)||
19723 //new only
19724 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19725 {
19726 //OLD-style items... sigh
19727
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 96 times.
99 if(s_version < 10)
19728 {
19729
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp,f,true))
19730 {
19731 return qe_invalid;
19732 }
19733
19734 3 temp_zinit.items[iRaft]=(temp != 0);
19735
19736
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp,f,true))
19737 {
19738 return qe_invalid;
19739 }
19740
19741 3 temp_zinit.items[iLadder]=(temp != 0);
19742
19743
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp,f,true))
19744 {
19745 return qe_invalid;
19746 }
19747
19748 3 temp_zinit.items[iBook]=(temp != 0);
19749
19750
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp,f,true))
19751 {
19752 return qe_invalid;
19753 }
19754
19755 3 temp_zinit.items[iMKey]=(temp!=0);
19756
19757
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp,f,true))
19758 {
19759 return qe_invalid;
19760 }
19761
19762 3 temp_zinit.items[iFlippers]=(temp != 0);
19763
19764
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp,f,true))
19765 {
19766 return qe_invalid;
19767 }
19768
19769 3 temp_zinit.items[iBoots]=(temp!=0);
19770 3 }
19771 99 }
19772
19773
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 151 times.
154 if(s_version < 10)
19774 {
19775 char tempring, tempsword, tempshield, tempwallet, tempbracelet, tempamulet, tempbow;
19776
19777
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&tempring,f,true))
19778 {
19779 return qe_invalid;
19780 }
19781
19782
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&tempsword,f,true))
19783 {
19784 return qe_invalid;
19785 }
19786
19787
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&tempshield,f,true))
19788 {
19789 return qe_invalid;
19790 }
19791
19792
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&tempwallet,f,true))
19793 {
19794 return qe_invalid;
19795 }
19796
19797
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&tempbracelet,f,true))
19798 {
19799 return qe_invalid;
19800 }
19801
19802
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&tempamulet,f,true))
19803 {
19804 return qe_invalid;
19805 }
19806
19807
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&tempbow,f,true))
19808 {
19809 return qe_invalid;
19810 }
19811
19812 //old only
19813
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if((Header->zelda_version == 0x192)&&(Header->build<174))
19814 {
19815 tempring=(tempring)?(1<<(tempring-1)):0;
19816 tempsword=(tempsword)?(1<<(tempsword-1)):0;
19817 tempshield=(tempshield)?(1<<(tempshield-1)):0;
19818 tempwallet=(tempwallet)?(1<<(tempwallet-1)):0;
19819 tempbracelet=(tempbracelet)?(1<<(tempbracelet-1)):0;
19820 tempamulet=(tempamulet)?(1<<(tempamulet-1)):0;
19821 tempbow=(tempbow)?(1<<(tempbow-1)):0;
19822 }
19823
19824 //rings start at level 2... wtf
19825 //account for this -DD
19826 3 tempring <<= 1;
19827
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 addOldStyleFamily(&temp_zinit, itemsbuf, itype_ring, tempring);
19828
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 addOldStyleFamily(&temp_zinit, itemsbuf, itype_sword, tempsword);
19829
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 addOldStyleFamily(&temp_zinit, itemsbuf, itype_shield, tempshield);
19830
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, tempwallet);
19831 //bracelet ALSO starts at level 2 :-( -DD
19832 3 tempbracelet<<=1;
19833
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bracelet, tempbracelet);
19834
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 addOldStyleFamily(&temp_zinit, itemsbuf, itype_amulet, tempamulet);
19835
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bow, tempbow);
19836
19837 //new only
19838
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if((Header->zelda_version == 0x192)&&(Header->build>173))
19839 {
19840 for(int32_t q=0; q<32; q++)
19841 {
19842 if(!p_getc(&padding,f,true))
19843 {
19844 return qe_invalid;
19845 }
19846 }
19847 }
19848
19849 char tempcandle, tempboomerang, temparrow, tempwhistle;
19850
19851
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&tempcandle,f,true))
19852 {
19853 return qe_invalid;
19854 }
19855
19856
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&tempboomerang,f,true))
19857 {
19858 return qe_invalid;
19859 }
19860
19861
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temparrow,f,true))
19862 {
19863 return qe_invalid;
19864 }
19865
19866
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp,f,true))
19867 {
19868 return qe_invalid;
19869 }
19870
19871
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 addOldStyleFamily(&temp_zinit, itemsbuf, itype_potion, temp);
19872
19873
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&tempwhistle,f,true))
19874 {
19875 return qe_invalid;
19876 }
19877
19878 //old only
19879
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if((Header->zelda_version == 0x192)&&(Header->build<174))
19880 {
19881 tempcandle=(tempcandle)?(1<<(tempcandle-1)):0;
19882 tempboomerang=(tempboomerang)?(1<<(tempboomerang-1)):0;
19883 temparrow=(temparrow)?(1<<(temparrow-1)):0;
19884 tempwhistle=(tempwhistle)?(1<<(tempwhistle-1)):0;
19885 }
19886
19887
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 addOldStyleFamily(&temp_zinit, itemsbuf, itype_candle, tempcandle);
19888
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 addOldStyleFamily(&temp_zinit, itemsbuf, itype_brang, tempboomerang);
19889
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 addOldStyleFamily(&temp_zinit, itemsbuf, itype_arrow, temparrow);
19890
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 addOldStyleFamily(&temp_zinit, itemsbuf, itype_whistle, tempwhistle);
19891 //What about the potion...?
19892
19893 3 }
19894
19895
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 77 times.
154 if(s_version < 29)
19896 {
19897 //Oh sure, stick these IN THE MIDDLE OF THE ITEMS, just to make me want
19898 //to jab out my eye...
19899
2/4
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
77 if(!p_getc(&padding,f,true))
19900 return qe_invalid;
19901 77 temp_zinit.bombs = padding;
19902
19903
2/4
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
77 if(!p_getc(&padding,f,true))
19904 return qe_invalid;
19905 77 temp_zinit.super_bombs = padding;
19906 77 }
19907
19908 //Back to more OLD item code
19909
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
154 if(s_version < 10)
19910 {
19911
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if((Header->zelda_version > 0x192)||
19912 //new only
19913 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19914 {
19915
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp,f,true))
19916 {
19917 return qe_invalid;
19918 }
19919
19920
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wand, temp);
19921
19922
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp,f,true))
19923 {
19924 return qe_invalid;
19925 }
19926
19927
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 addOldStyleFamily(&temp_zinit, itemsbuf, itype_letter, temp);
19928
19929
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp,f,true))
19930 {
19931 return qe_invalid;
19932 }
19933
19934
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 addOldStyleFamily(&temp_zinit, itemsbuf, itype_lens, temp);
19935
19936
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp,f,true))
19937 {
19938 return qe_invalid;
19939 }
19940
19941
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hookshot, temp);
19942
19943
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp,f,true))
19944 {
19945 return qe_invalid;
19946 }
19947
19948
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bait, temp);
19949
19950
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp,f,true))
19951 {
19952 return qe_invalid;
19953 }
19954
19955
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hammer, temp);
19956
19957
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp,f,true))
19958 {
19959 return qe_invalid;
19960 }
19961
19962
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 addOldStyleFamily(&temp_zinit, itemsbuf, itype_dinsfire, temp);
19963
19964
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp,f,true))
19965 {
19966 return qe_invalid;
19967 }
19968
19969
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 addOldStyleFamily(&temp_zinit, itemsbuf, itype_faroreswind, temp);
19970
19971
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp,f,true))
19972 {
19973 return qe_invalid;
19974 }
19975
19976
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 addOldStyleFamily(&temp_zinit, itemsbuf, itype_nayruslove, temp);
19977
19978
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp,f,true))
19979 {
19980 return qe_invalid;
19981 }
19982
19983
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(Header->zelda_version == 0x192)
19984 {
19985 for(int32_t q=0; q<32; q++)
19986 {
19987 if(!p_getc(&padding,f,true))
19988 {
19989 return qe_invalid;
19990 }
19991 }
19992 }
19993 3 }
19994 3 }
19995
19996 //old only
19997
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
6 if((Header->zelda_version == 0x192)&&(Header->build<174))
19998 {
19999 byte equipment, items; //bit flags
20000
20001 if(!p_getc(&equipment,f,true))
20002 {
20003 return qe_invalid;
20004 }
20005
20006 temp_zinit.items[iRaft]=(get_bit(&equipment, idE_RAFT)!=0);
20007 temp_zinit.items[iLadder]=(get_bit(&equipment, idE_LADDER)!=0);
20008 temp_zinit.items[iBook]=(get_bit(&equipment, idE_BOOK)!=0);
20009 temp_zinit.items[iMKey]=(get_bit(&equipment, idE_KEY)!=0);
20010 temp_zinit.items[iFlippers]=(get_bit(&equipment, idE_FLIPPERS)!=0);
20011 temp_zinit.items[iBoots]=(get_bit(&equipment, idE_BOOTS)!=0);
20012
20013
20014 if(!p_getc(&items,f,true))
20015 {
20016 return qe_invalid;
20017 }
20018
20019 temp_zinit.items[iWand]=(get_bit(&items, idI_WAND)!=0);
20020 temp_zinit.items[iLetter]=(get_bit(&items, idI_LETTER)!=0);
20021 temp_zinit.items[iLens]=(get_bit(&items, idI_LENS)!=0);
20022 temp_zinit.items[iHookshot]=(get_bit(&items, idI_HOOKSHOT)!=0);
20023 temp_zinit.items[iBait]=(get_bit(&items, idI_BAIT)!=0);
20024 temp_zinit.items[iHammer]=(get_bit(&items, idI_HAMMER)!=0);
20025 }
20026
20027 if(!p_getc(&temp_zinit.hc,f,true))
20028 {
20029 return qe_invalid;
20030 }
20031
20032
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 96 times.
99 if(s_version < 14)
20033 {
20034 byte temphp;
20035
20036
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temphp,f,true))
20037 {
20038 return qe_invalid;
20039 }
20040
20041 3 temp_zinit.start_heart=temphp;
20042
20043
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temphp,f,true))
20044 {
20045 return qe_invalid;
20046 }
20047
20048 3 temp_zinit.cont_heart=temphp;
20049 3 }
20050 else
20051 {
20052
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_igetw(&temp_zinit.start_heart,f,true))
20053 {
20054 return qe_invalid;
20055 }
20056
20057
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_igetw(&temp_zinit.cont_heart,f,true))
20058 {
20059 return qe_invalid;
20060 }
20061 }
20062
20063
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_getc(&temp_zinit.hcp,f,true))
20064 {
20065 return qe_invalid;
20066 }
20067
20068
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version >= 14)
20069 {
20070
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_getc(&temp_zinit.hcp_per_hc,f,true))
20071 {
20072 return qe_invalid;
20073 }
20074
20075
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(s_version<16) // July 2007
20076 {
20077 if(get_bit(quest_rules,qr_BRANGPICKUP+1))
20078 temp_zinit.hcp_per_hc = 0xFF;
20079
20080 //Dispose of legacy rule
20081 set_bit(quest_rules,qr_BRANGPICKUP+1, 0);
20082 }
20083 96 }
20084
20085
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 22 times.
99 if(s_version < 29)
20086 {
20087
2/4
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
77 if(!p_getc(&padding,f,true))
20088 return qe_invalid;
20089 77 temp_zinit.max_bombs = padding;
20090 77 }
20091
20092
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_getc(&temp_zinit.keys,f,true))
20093 {
20094 return qe_invalid;
20095 }
20096
20097
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_igetw(&temp_zinit.rupies,f,true))
20098 {
20099 return qe_invalid;
20100 }
20101
20102
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_getc(&temp_zinit.triforce,f,true))
20103 {
20104 return qe_invalid;
20105 }
20106
20107
3/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 96 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
20108 {
20109
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 96 times.
6240 for(int32_t i=0; i<64; i++)
20110 {
20111
2/4
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6144 times.
6144 if(!p_getc(&temp_zinit.map[i],f,true))
20112 {
20113 return qe_invalid;
20114 }
20115 6144 }
20116
20117
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 96 times.
6240 for(int32_t i=0; i<64; i++)
20118 {
20119
2/4
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6144 times.
6144 if(!p_getc(&temp_zinit.compass[i],f,true))
20120 {
20121 return qe_invalid;
20122 }
20123 6144 }
20124 96 }
20125 else
20126 {
20127
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 for(int32_t i=0; i<32; i++)
20128 {
20129
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 96 times.
96 if(!p_getc(&temp_zinit.map[i],f,true))
20130 {
20131 return qe_invalid;
20132 }
20133 96 }
20134
20135
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 for(int32_t i=0; i<32; i++)
20136 {
20137
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 96 times.
96 if(!p_getc(&temp_zinit.compass[i],f,true))
20138 {
20139 return qe_invalid;
20140 }
20141 96 }
20142 }
20143
20144
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
99 if((Header->zelda_version > 0x192)||
20145 //new only
20146 ((Header->zelda_version == 0x192)&&(Header->build>173)))
20147 {
20148
3/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 96 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
20149 {
20150
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 96 times.
6240 for(int32_t i=0; i<64; i++)
20151 {
20152
2/4
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6144 times.
6144 if(!p_getc(&temp_zinit.boss_key[i],f,true))
20153 {
20154 return qe_invalid;
20155 }
20156 6144 }
20157 96 }
20158 else
20159 {
20160
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 for(int32_t i=0; i<32; i++)
20161 {
20162
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_getc(&temp_zinit.boss_key[i],f,true))
20163 {
20164 return qe_invalid;
20165 }
20166 96 }
20167 }
20168 99 }
20169
20170
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 1584 times.
1683 for(int32_t i=0; i<16; i++)
20171 {
20172
2/4
✓ Branch 0 taken 1584 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1584 times.
1584 if(!p_getc(&temp_zinit.misc[i],f,true))
20173 {
20174 return qe_invalid;
20175 }
20176 1584 }
20177
20178
4/4
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 3 times.
111 if(s_version < 15) for(int32_t i=0; i<4; i++)
20179 {
20180
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&sword_hearts[i],f,true))
20181 {
20182 return qe_invalid;
20183 }
20184 15 }
20185
20186
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_getc(&temp_zinit.last_map,f,true))
20187 {
20188 return qe_invalid;
20189 }
20190
20191
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_getc(&temp_zinit.last_screen,f,true))
20192 {
20193 return qe_invalid;
20194 }
20195
20196
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 96 times.
99 if(s_version < 14)
20197 {
20198 byte tempmp;
20199
20200
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&tempmp,f,true))
20201 {
20202 return qe_invalid;
20203 }
20204
20205 3 temp_zinit.max_magic=tempmp;
20206
20207
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&tempmp,f,true))
20208 {
20209 return qe_invalid;
20210 }
20211
20212 3 temp_zinit.magic=tempmp;
20213 3 }
20214 else
20215 {
20216
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_igetw(&temp_zinit.max_magic,f,true))
20217 {
20218 return qe_invalid;
20219 }
20220
20221
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_igetw(&temp_zinit.magic,f,true))
20222 {
20223 return qe_invalid;
20224 }
20225 }
20226
20227
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version < 15)
20228 {
20229
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(s_version < 12)
20230 {
20231 3 temp_zinit.max_magic*=32;
20232 3 temp_zinit.magic*=32;
20233 3 }
20234
20235
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 12 times.
15 for(int32_t i=0; i<4; i++)
20236 {
20237
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&beam_hearts[i],f,true))
20238 {
20239 return qe_invalid;
20240 }
20241 12 }
20242
20243
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&beam_percent,f,true))
20244 {
20245 return qe_invalid;
20246 }
20247 3 }
20248 else
20249 {
20250
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_getc(&temp_zinit.bomb_ratio,f,true))
20251 {
20252 return qe_invalid;
20253 }
20254 }
20255
20256
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version < 15)
20257 {
20258 byte tempbp;
20259
20260
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 12 times.
15 for(int32_t i=0; i<4; i++)
20261 {
20262
3/8
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
12 if(!(s_version < 14 ? p_getc(&tempbp,f,true) : p_igetw(&tempbp,f,true)))
20263 {
20264 return qe_invalid;
20265 }
20266
20267 12 beam_power[i]=tempbp;
20268 12 }
20269
20270
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&hookshot_links,f,true))
20271 {
20272 return qe_invalid;
20273 }
20274
20275
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(s_version>6)
20276 {
20277 if(!p_getc(&hookshot_length,f,true))
20278 {
20279 return qe_invalid;
20280 }
20281
20282 if(!p_getc(&longshot_links,f,true))
20283 {
20284 return qe_invalid;
20285 }
20286
20287 if(!p_getc(&longshot_length,f,true))
20288 {
20289 return qe_invalid;
20290 }
20291 }
20292 3 }
20293
20294
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_getc(&temp_zinit.msg_more_x,f,true))
20295 {
20296 return qe_invalid;
20297 }
20298
20299
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_getc(&temp_zinit.msg_more_y,f,true))
20300 {
20301 return qe_invalid;
20302 }
20303
20304
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_getc(&temp_zinit.subscreen,f,true))
20305 {
20306 return qe_invalid;
20307 }
20308
20309 //old only
20310
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
99 if((Header->zelda_version == 0x192)&&(Header->build<174))
20311 {
20312 for(int32_t i=0; i<32; i++)
20313 {
20314 if(!p_getc(&temp_zinit.boss_key[i],f,true))
20315 {
20316 return qe_invalid;
20317 }
20318 }
20319 }
20320
20321
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>173))) //new only
20322 {
20323
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 96 times.
99 if(s_version <= 10)
20324 {
20325 byte tempbyte;
20326
20327
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&tempbyte,f,true))
20328 {
20329 return qe_invalid;
20330 }
20331
20332 3 temp_zinit.start_dmap = (word)tempbyte;
20333 3 }
20334 else
20335 {
20336
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_igetw(&temp_zinit.start_dmap,f,true))
20337 {
20338 return qe_invalid;
20339 }
20340 }
20341
20342
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_getc(&temp_zinit.heroAnimationStyle,f,true))
20343 {
20344 return qe_invalid;
20345 }
20346 99 }
20347
20348
4/4
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 74 times.
✓ Branch 3 taken 22 times.
99 if(s_version>1 && s_version < 29)
20349 {
20350
2/4
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 74 times.
✗ Branch 3 not taken.
74 if(!p_getc(&padding,f,true))
20351 return qe_invalid;
20352 74 temp_zinit.arrows = padding;
20353
20354
2/4
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 74 times.
✗ Branch 3 not taken.
74 if(!p_getc(&padding,f,true))
20355 return qe_invalid;
20356 74 temp_zinit.max_arrows = padding;
20357 74 }
20358
20359
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 96 times.
99 if(s_version>2)
20360 {
20361
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(s_version <= 10)
20362 {
20363 for(int32_t i=0; i<OLDMAXLEVELS; i++)
20364 {
20365 if(!p_getc(&(temp_zinit.level_keys[i]),f,true))
20366 {
20367 return qe_invalid;
20368 }
20369 }
20370 }
20371 else
20372 {
20373
2/2
✓ Branch 0 taken 49152 times.
✓ Branch 1 taken 96 times.
49248 for(int32_t i=0; i<MAXLEVELS; i++)
20374 {
20375
2/4
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 49152 times.
✗ Branch 3 not taken.
49152 if(!p_getc(&(temp_zinit.level_keys[i]),f,true))
20376 {
20377 return qe_invalid;
20378 }
20379 49152 }
20380 }
20381 96 }
20382
20383
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version>3)
20384 {
20385
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_igetw(&temp_zinit.ss_grid_x,f,true))
20386 {
20387 return qe_invalid;
20388 }
20389
20390
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_igetw(&temp_zinit.ss_grid_y,f,true))
20391 {
20392 return qe_invalid;
20393 }
20394
20395
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_igetw(&temp_zinit.ss_grid_xofs,f,true))
20396 {
20397 return qe_invalid;
20398 }
20399
20400
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_igetw(&temp_zinit.ss_grid_yofs,f,true))
20401 {
20402 return qe_invalid;
20403 }
20404
20405
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_igetw(&temp_zinit.ss_grid_color,f,true))
20406 {
20407 return qe_invalid;
20408 }
20409
20410
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_igetw(&temp_zinit.ss_bbox_1_color,f,true))
20411 {
20412 return qe_invalid;
20413 }
20414
20415
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_igetw(&temp_zinit.ss_bbox_2_color,f,true))
20416 {
20417 return qe_invalid;
20418 }
20419
20420
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_igetw(&temp_zinit.ss_flags,f,true))
20421 {
20422 return qe_invalid;
20423 }
20424
20425
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 temp_zinit.ss_grid_x=zc_max(temp_zinit.ss_grid_x,1);
20426
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 temp_zinit.ss_grid_y=zc_max(temp_zinit.ss_grid_y,1);
20427 96 }
20428
20429
3/4
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 96 times.
99 if(s_version>4 && s_version<15)
20430 {
20431 if(!p_getc(&moving_fairy_hearts,f,true))
20432 {
20433 return qe_invalid;
20434 }
20435
20436 if(!p_getc(&moving_fairy_heart_percent,f,true))
20437 {
20438 return qe_invalid;
20439 }
20440 }
20441
20442
3/4
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 96 times.
99 if(s_version>5 && s_version < 10)
20443 {
20444 if(!p_getc(&temp,f,true))
20445 {
20446 return qe_invalid;
20447 }
20448
20449 addOldStyleFamily(&temp_zinit, itemsbuf, itype_quiver, temp);
20450 }
20451
20452
3/4
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 96 times.
99 if(s_version>6 && s_version<15)
20453 {
20454 if(!p_getc(&stationary_fairy_hearts,f,true))
20455 {
20456 return qe_invalid;
20457 }
20458
20459 if(!p_getc(&stationary_fairy_heart_percent,f,true))
20460 {
20461 return qe_invalid;
20462 }
20463
20464 if(!p_getc(&moving_fairy_magic,f,true))
20465 {
20466 return qe_invalid;
20467 }
20468
20469 if(!p_getc(&moving_fairy_magic_percent,f,true))
20470 {
20471 return qe_invalid;
20472 }
20473
20474 if(!p_getc(&stationary_fairy_magic,f,true))
20475 {
20476 return qe_invalid;
20477 }
20478
20479 if(!p_getc(&stationary_fairy_magic_percent,f,true))
20480 {
20481 return qe_invalid;
20482 }
20483
20484 if(!p_getc(&blue_potion_hearts,f,true))
20485 {
20486 return qe_invalid;
20487 }
20488
20489 if(!p_getc(&blue_potion_heart_percent,f,true))
20490 {
20491 return qe_invalid;
20492 }
20493
20494 if(!p_getc(&red_potion_hearts,f,true))
20495 {
20496 return qe_invalid;
20497 }
20498
20499 if(!p_getc(&red_potion_heart_percent,f,true))
20500 {
20501 return qe_invalid;
20502 }
20503
20504 if(!p_getc(&blue_potion_magic,f,true))
20505 {
20506 return qe_invalid;
20507 }
20508
20509 if(!p_getc(&blue_potion_magic_percent,f,true))
20510 {
20511 return qe_invalid;
20512 }
20513
20514 if(!p_getc(&red_potion_magic,f,true))
20515 {
20516 return qe_invalid;
20517 }
20518
20519 if(!p_getc(&red_potion_magic_percent,f,true))
20520 {
20521 return qe_invalid;
20522 }
20523 }
20524
20525
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version>6)
20526 {
20527
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_getc(&temp_zinit.subscreen_style,f,true))
20528 {
20529 return qe_invalid;
20530 }
20531 96 }
20532
20533
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version>7)
20534 {
20535
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_getc(&temp_zinit.usecustomsfx,f,true))
20536 {
20537 return qe_invalid;
20538 }
20539 96 }
20540
20541
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version>8)
20542 {
20543
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_igetw(&temp_zinit.max_rupees,f,true))
20544 {
20545 return qe_invalid;
20546 }
20547
20548
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_igetw(&temp_zinit.max_keys,f,true))
20549 {
20550 return qe_invalid;
20551 }
20552 96 }
20553
20554
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version>16)
20555 {
20556
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_getc(&temp_zinit.gravity,f,true))
20557 {
20558 return qe_invalid;
20559 }
20560
20561
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_igetw(&temp_zinit.terminalv,f,true))
20562 {
20563 return qe_invalid;
20564 }
20565
20566
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_getc(&temp_zinit.msg_speed,f,true))
20567 {
20568 return qe_invalid;
20569 }
20570
20571
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_getc(&temp_zinit.transition_type,f,true))
20572 {
20573 return qe_invalid;
20574 }
20575
20576
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_getc(&temp_zinit.jump_hero_layer_threshold,f,true))
20577 {
20578 return qe_invalid;
20579 }
20580 96 }
20581
4/8
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 3 times.
3 else if(replay_is_replaying() && replay_get_version() < 13)
20582 3 temp_zinit.msg_speed = 0;
20583
20584
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version>17)
20585 {
20586
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_getc(&temp_zinit.msg_more_is_offset,f,true))
20587 {
20588 return qe_invalid;
20589 }
20590 96 }
20591
20592 //expaned init data for larger values in 2.55
20593
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if ( s_version >= 19 ) //expand init data bombs, sbombs, and arrows to 0xFFFF
20594 {
20595
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_igetw(&temp_zinit.bombs,f,true))
20596 {
20597 return qe_invalid;
20598 }
20599
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_igetw(&temp_zinit.super_bombs,f,true))
20600 {
20601 return qe_invalid;
20602 }
20603
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_igetw(&temp_zinit.max_bombs,f,true))
20604 {
20605 return qe_invalid;
20606 }
20607
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_igetw(&temp_zinit.max_sbombs,f,true))
20608 {
20609 return qe_invalid;
20610 }
20611
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_igetw(&temp_zinit.arrows,f,true))
20612 {
20613 return qe_invalid;
20614 }
20615
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_igetw(&temp_zinit.max_arrows,f,true))
20616 {
20617 return qe_invalid;
20618 }
20619
20620 22 }
20621
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if ( s_version >= 20 )
20622 {
20623
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_igetw(&temp_zinit.heroStep,f,true))
20624 {
20625 return qe_invalid;
20626 }
20627 22 }
20628 else
20629 {
20630 77 temp_zinit.heroStep = 150; //1.5 pixels per frame
20631 }
20632
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if ( s_version >= 21 )
20633 {
20634
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_igetw(&temp_zinit.subscrSpeed,f,true))
20635 {
20636 return qe_invalid;
20637 }
20638 22 }
20639 else
20640 {
20641 77 temp_zinit.subscrSpeed = 1; //3 pixels per frame
20642 }
20643 //old only
20644
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
99 if((Header->zelda_version == 0x192)&&(Header->build<174))
20645 {
20646 byte items2;
20647
20648 if(!p_getc(&items2,f,true))
20649 {
20650 return qe_invalid;
20651 }
20652
20653 temp_zinit.items[iDinsFire]=(get_bit(&items2, idI_DFIRE)!=0);
20654 temp_zinit.items[iFaroresWind]=(get_bit(&items2, idI_FWIND)!=0);
20655 temp_zinit.items[iNayrusLove]=(get_bit(&items2, idI_NLOVE)!=0);
20656 }
20657
20658
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(Header->zelda_version < 0x193)
20659 {
20660 for(int32_t q=0; q<96; q++)
20661 {
20662 if(!p_getc(&padding,f,true))
20663 {
20664 return qe_invalid;
20665 }
20666 }
20667
20668 //new only
20669 if((Header->zelda_version == 0x192)&&(Header->build>173))
20670 {
20671 if(!p_getc(&padding,f,true))
20672 {
20673 return qe_invalid;
20674 }
20675
20676 if(!p_getc(&padding,f,true))
20677 {
20678 return qe_invalid;
20679 }
20680 }
20681 }
20682 99 }
20683
20684
3/6
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 58 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 96 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
154 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<15)))
20685 {
20686 //temp_zinit.shield=i_smallshield;
20687
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 int32_t sshieldid = getItemID(itemsbuf, itype_shield, i_smallshield);
20688
20689
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(sshieldid != -1)
20690 3 temp_zinit.items[sshieldid] = true;
20691 3 }
20692
20693
2/6
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<27)))
20694 {
20695 temp_zinit.hc=3;
20696 temp_zinit.start_heart=3;
20697 temp_zinit.cont_heart=3;
20698 temp_zinit.max_bombs=8;
20699 }
20700
20701
2/6
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<50)))
20702 {
20703 sword_hearts[0]=0;
20704 sword_hearts[1]=5;
20705 sword_hearts[2]=12;
20706 sword_hearts[3]=21;
20707 }
20708
20709
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
99 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<51)))
20710 {
20711 temp_zinit.last_map=0;
20712 temp_zinit.last_screen=0;
20713 }
20714
20715
2/6
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<68)))
20716 {
20717 temp_zinit.max_magic=0;
20718 temp_zinit.magic=0;
20719 set_bit(temp_zinit.misc,idM_DOUBLEMAGIC,0);
20720 }
20721
20722
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
99 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<129)))
20723 {
20724
20725 for(int32_t x=0; x<4; x++)
20726 {
20727 beam_hearts[x]=100;
20728 }
20729
20730 for(int32_t i=0; i<idBP_MAX; i++)
20731 {
20732 set_bit(&beam_percent,i,!get_bit(quest_rules,qr_LENSHINTS+i));
20733 set_bit(quest_rules,qr_LENSHINTS+i,0);
20734 }
20735
20736 for(int32_t x=0; x<4; x++)
20737 {
20738 beam_power[x]=get_bit(quest_rules,qr_HIDECARRIEDITEMS)?50:100;
20739 }
20740
20741 set_bit(quest_rules,qr_HIDECARRIEDITEMS,0);
20742 hookshot_links=100;
20743 temp_zinit.msg_more_x=224;
20744 temp_zinit.msg_more_y=64;
20745 }
20746
20747 // Okay, let's put these legacy values into itemsbuf.
20748
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version < 15)
20749
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 768 times.
771 for(int32_t i=0; i<MAXITEMS; i++)
20750 {
20751
11/11
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 738 times.
✓ Branch 9 taken 3 times.
✓ Branch 10 taken 3 times.
768 switch(i)
20752 {
20753 case iFairyStill:
20754 3 itemsbuf[i].misc1 = stationary_fairy_hearts;
20755 3 itemsbuf[i].misc2 = stationary_fairy_magic;
20756 3 itemsbuf[i].misc3 = 0;
20757 3 itemsbuf[i].flags |= stationary_fairy_heart_percent ? ITEM_FLAG1 : 0;
20758 3 itemsbuf[i].flags |= stationary_fairy_magic_percent ? ITEM_FLAG2 : 0;
20759 3 break;
20760
20761 case iFairyMoving:
20762 3 itemsbuf[i].misc1 = moving_fairy_hearts;
20763 3 itemsbuf[i].misc2 = moving_fairy_magic;
20764 3 itemsbuf[i].misc3 = 50;
20765 3 itemsbuf[i].flags |= moving_fairy_heart_percent ? ITEM_FLAG1 : 0;
20766 3 itemsbuf[i].flags |= moving_fairy_magic_percent ? ITEM_FLAG2 : 0;
20767 3 break;
20768
20769 case iRPotion:
20770 3 itemsbuf[i].misc1 = red_potion_hearts;
20771 3 itemsbuf[i].misc2 = red_potion_magic;
20772 3 itemsbuf[i].flags |= red_potion_heart_percent ? ITEM_FLAG1 : 0;
20773 3 itemsbuf[i].flags |= red_potion_magic_percent ? ITEM_FLAG2 : 0;
20774 3 break;
20775
20776 case iBPotion:
20777 3 itemsbuf[i].misc1 = blue_potion_hearts;
20778 3 itemsbuf[i].misc2 = blue_potion_magic;
20779 3 itemsbuf[i].flags |= blue_potion_heart_percent ? ITEM_FLAG1 : 0;
20780 3 itemsbuf[i].flags |= blue_potion_magic_percent ? ITEM_FLAG2 : 0;
20781 3 break;
20782
20783 case iSword:
20784 3 itemsbuf[i].pickup_hearts = sword_hearts[0];
20785 3 itemsbuf[i].misc1 = beam_hearts[0];
20786 3 itemsbuf[i].misc2 = beam_power[0];
20787 // It seems that ITEM_FLAG1 was already added by reset_itembuf()...
20788
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 itemsbuf[i].flags &= (!get_bit(&beam_percent,0)) ? ~ITEM_FLAG1 : ~0;
20789 3 break;
20790
20791 case iWSword:
20792 3 itemsbuf[i].pickup_hearts = sword_hearts[1];
20793 3 itemsbuf[i].misc1 = beam_hearts[1];
20794 3 itemsbuf[i].misc2 = beam_power[1];
20795
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 itemsbuf[i].flags &= (!get_bit(&beam_percent,1)) ? ~ITEM_FLAG1 : ~0;
20796 3 break;
20797
20798 case iMSword:
20799 3 itemsbuf[i].pickup_hearts = sword_hearts[2];
20800 3 itemsbuf[i].misc1 = beam_hearts[2];
20801 3 itemsbuf[i].misc2 = beam_power[2];
20802
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 itemsbuf[i].flags &= (!get_bit(&beam_percent,2)) ? ~ITEM_FLAG1 : ~0;
20803 3 break;
20804
20805 case iXSword:
20806 3 itemsbuf[i].pickup_hearts = sword_hearts[3];
20807 3 itemsbuf[i].misc1 = beam_hearts[3];
20808 3 itemsbuf[i].misc2 = beam_power[3];
20809
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 itemsbuf[i].flags &= (!get_bit(&beam_percent,3)) ? ~ITEM_FLAG1 : ~0;
20810 3 break;
20811
20812 case iHookshot:
20813 3 itemsbuf[i].misc1 = hookshot_length;
20814 3 itemsbuf[i].misc2 = hookshot_links;
20815 3 break;
20816
20817 case iLongshot:
20818 3 itemsbuf[i].misc1 = longshot_length;
20819 3 itemsbuf[i].misc2 = longshot_links;
20820 3 break;
20821 }
20822 771 }
20823
20824
2/6
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<168)))
20825 {
20826 //was new subscreen rule
20827 temp_zinit.subscreen=get_bit(quest_rules,qr_FREEFORM)?1:0;
20828 set_bit(quest_rules,qr_FREEFORM,0);
20829 }
20830
20831
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
99 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<185)))
20832 {
20833 temp_zinit.start_dmap=0;
20834 }
20835
20836
2/6
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<186)))
20837 {
20838 temp_zinit.heroAnimationStyle=get_bit(quest_rules,qr_BSZELDA)?1:0;
20839 }
20840
20841
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 96 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
99 if(s_version < 16 && get_bit(deprecated_rules, qr_COOLSCROLL+1))
20842 {
20843 //addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, 4); //is this needed?
20844 temp_zinit.max_rupees=999;
20845 //temp_zinit.rupies=999; //This rule only gave you an invisible max wallet; it did not give you max rupies.
20846 }
20847
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(Header->zelda_version < 0x190) //1.84 bugfix. -Z
20848 {
20849 //temp_zinit.items[iBombBag] = true; //No, this is 30 max bombs!
20850 temp_zinit.max_bombs = 8;
20851 }
20852 // al_trace("About to copy over new init data values for quest made in: %x\n", Header->zelda_version);
20853 //time to ensure that we port all new values properly:
20854
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(Header->zelda_version < 0x250)
20855 {
20856
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 temp_zinit.max_sbombs = temp_zinit.bomb_ratio > 0 ? ( temp_zinit.max_bombs/temp_zinit.bomb_ratio ) : (temp_zinit.max_bombs/4);
20857 3 }
20858
20859
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(s_version > 21)
20860 {
20861
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_getc(&temp_zinit.hp_per_heart,f,true))
20862 {
20863 return qe_invalid;
20864 }
20865
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_getc(&temp_zinit.magic_per_block,f,true))
20866 {
20867 return qe_invalid;
20868 }
20869
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_getc(&temp_zinit.hero_damage_multiplier,f,true))
20870 {
20871 return qe_invalid;
20872 }
20873
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_getc(&temp_zinit.ene_damage_multiplier,f,true))
20874 {
20875 return qe_invalid;
20876 }
20877 22 }
20878 else
20879 {
20880 77 temp_zinit.hp_per_heart = 16; //HP_PER_HEART, previously hardcoded
20881 77 temp_zinit.magic_per_block = 32; //MAGICPERBLOCK, previously hardcoded
20882 77 temp_zinit.hero_damage_multiplier = 2; //DAMAGE_MULTIPLIER, previously hardcoded
20883 77 temp_zinit.ene_damage_multiplier = 4; //(HP_PER_HEART/4), previously hardcoded
20884 }
20885
20886
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(s_version > 22)
20887 {
20888
2/2
✓ Branch 0 taken 550 times.
✓ Branch 1 taken 22 times.
572 for(int32_t q = 0; q < 25; ++q)
20889 {
20890
2/4
✓ Branch 0 taken 550 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 550 times.
550 if(!p_igetw(&temp_zinit.scrcnt[q],f,true))
20891 {
20892 return qe_invalid;
20893 }
20894 550 }
20895
2/2
✓ Branch 0 taken 550 times.
✓ Branch 1 taken 22 times.
572 for(int32_t q = 0; q < 25; ++q)
20896 {
20897
2/4
✓ Branch 0 taken 550 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 550 times.
550 if(!p_igetw(&temp_zinit.scrmaxcnt[q],f,true))
20898 {
20899 return qe_invalid;
20900 }
20901 550 }
20902 22 }
20903 else
20904 {
20905
2/2
✓ Branch 0 taken 1925 times.
✓ Branch 1 taken 77 times.
2002 for(int32_t q = 0; q < 25; ++q)
20906 {
20907 1925 temp_zinit.scrcnt[q] = 0;
20908 1925 temp_zinit.scrmaxcnt[q] = 0;
20909 1925 }
20910 }
20911
20912
20913
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(s_version > 23)
20914 {
20915
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_getc(&temp_zinit.dither_type,f,true))
20916 {
20917 return qe_invalid;
20918 }
20919
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_getc(&temp_zinit.dither_arg,f,true))
20920 {
20921 return qe_invalid;
20922 }
20923
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_getc(&temp_zinit.dither_percent,f,true))
20924 {
20925 return qe_invalid;
20926 }
20927
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_getc(&temp_zinit.def_lightrad,f,true))
20928 {
20929 return qe_invalid;
20930 }
20931
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_getc(&temp_zinit.transdark_percent,f,true))
20932 {
20933 return qe_invalid;
20934 }
20935 22 }
20936 else
20937 {
20938 77 temp_zinit.dither_type = 0;
20939 77 temp_zinit.dither_arg = 0;
20940 77 temp_zinit.dither_percent = 20;
20941 77 temp_zinit.def_lightrad = 24;
20942 77 temp_zinit.transdark_percent = 0;
20943 }
20944
20945
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(s_version > 24)
20946 {
20947
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_getc(&temp_zinit.darkcol,f,true))
20948 {
20949 return qe_invalid;
20950 }
20951 22 }
20952 else
20953 {
20954 77 temp_zinit.darkcol = BLACK;
20955 }
20956
20957
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(s_version > 25)
20958 {
20959
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_igetl(&temp_zinit.gravity2,f,true))
20960 {
20961 return qe_invalid;
20962 }
20963
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_igetl(&temp_zinit.swimgravity,f,true))
20964 {
20965 return qe_invalid;
20966 }
20967 22 }
20968 else
20969 {
20970 77 temp_zinit.gravity2 = temp_zinit.gravity*100;
20971 77 temp_zinit.swimgravity = 5;
20972 }
20973
20974
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(s_version > 26)
20975 {
20976
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_igetw(&temp_zinit.heroSideswimUpStep,f,true))
20977 {
20978 return qe_invalid;
20979 }
20980
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_igetw(&temp_zinit.heroSideswimSideStep,f,true))
20981 {
20982 return qe_invalid;
20983 }
20984
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_igetw(&temp_zinit.heroSideswimDownStep,f,true))
20985 {
20986 return qe_invalid;
20987 }
20988 22 }
20989 else
20990 {
20991 77 temp_zinit.heroSideswimUpStep = 150;
20992 77 temp_zinit.heroSideswimSideStep = 100;
20993 77 temp_zinit.heroSideswimDownStep = 75;
20994 }
20995
20996
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(s_version > 27)
20997 {
20998
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_igetl(&temp_zinit.exitWaterJump,f,true))
20999 {
21000 return qe_invalid;
21001 }
21002 22 }
21003 else
21004 {
21005 77 temp_zinit.exitWaterJump = 0;
21006 }
21007
21008
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(s_version > 29)
21009 {
21010
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_igetl(&temp_zinit.bunny_ltm,f,true))
21011 {
21012 return qe_invalid;
21013 }
21014 22 }
21015 else
21016 {
21017 77 temp_zinit.bunny_ltm = 0;
21018 }
21019
21020
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(s_version > 30)
21021 {
21022
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_getc(&temp_zinit.switchhookstyle,f,true))
21023 {
21024 return qe_invalid;
21025 }
21026 22 }
21027 else
21028 {
21029 77 temp_zinit.switchhookstyle = 1;
21030 }
21031
21032
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(s_version > 31)
21033 {
21034
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_getc(&temp_zinit.magicdrainrate,f,true))
21035 {
21036 return qe_invalid;
21037 }
21038 22 }
21039 else
21040 {
21041
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 temp_zinit.magicdrainrate = (get_bit(temp_zinit.misc,idM_DOUBLEMAGIC) ? 1 : 2);
21042
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 set_bit(temp_zinit.misc,idM_DOUBLEMAGIC,0);
21043 }
21044
21045
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 temp_zinit.clear_genscript();
21046
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 86 times.
99 if(s_version > 32)
21047 {
21048 13 word numgenscript = 0;
21049
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if(!p_igetw(&numgenscript,f,true))
21050 return qe_invalid;
21051
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 1 times.
14 for(auto q = 1; q < numgenscript; ++q)
21052 {
21053
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(!p_getc(&padding,f,true))
21054 return qe_invalid;
21055
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!(padding&2))
21056 continue;
21057 1 temp_zinit.gen_doscript[q] = padding&1;
21058
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(!p_igetw(&temp_zinit.gen_exitState[q],f,true))
21059 return qe_invalid;
21060
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(!p_igetw(&temp_zinit.gen_reloadState[q],f,true))
21061 return qe_invalid;
21062
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 8 times.
9 for(auto p = 0; p < 8; ++p)
21063
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
8 if(!p_igetl(&temp_zinit.gen_initd[q][p],f,true))
21064 return qe_invalid;
21065
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(!p_igetl(&temp_zinit.gen_dataSize[q],f,true))
21066 return qe_invalid;
21067
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(!p_getlvec<int32_t>(&temp_zinit.gen_data[q],f,true))
21068 return qe_invalid;
21069
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(!p_igetl(&temp_zinit.gen_eventstate[q],f,true))
21070 return qe_invalid;
21071 1 }
21072 13 }
21073
21074
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(keepdata==true)
21075 {
21076
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 zinit = temp_zinit;
21077
21078
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(zinit.heroAnimationStyle==las_zelda3slow)
21079 {
21080 hero_animation_speed=2;
21081 }
21082 else
21083 {
21084 99 hero_animation_speed=1;
21085 }
21086 99 }
21087
21088 99 return 0;
21089 407 }
21090
21091 /*
21092 void setupitemdropsets()
21093 {
21094 for(int32_t i=0; i<isMAX; i++)
21095 {
21096 memcpy(&item_drop_sets[i], &default_item_drop_sets[i], sizeof(item_drop_object));
21097 }
21098 }
21099 */
21100
21101 96 int32_t readitemdropsets(PACKFILE *f, int32_t version, word build, bool keepdata)
21102 {
21103 96 build=build; // here to prevent compiler warnings
21104 dword dummy_dword;
21105 96 word item_drop_sets_to_read=0;
21106 item_drop_object tempitemdrop;
21107 96 word s_version=0, s_cversion=0;
21108
21109
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(keepdata)
21110 {
21111
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 96 times.
24672 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
21112 {
21113 24576 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
21114 24576 }
21115 96 }
21116
21117
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(version > 0x192)
21118 {
21119 96 item_drop_sets_to_read=0;
21120
21121 //section version info
21122
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetw(&s_version,f,true))
21123 {
21124 return qe_invalid;
21125 }
21126
21127 96 FFCore.quest_format[vItemDropsets] = s_version;
21128
21129 //al_trace("Item drop sets version %d\n", s_version);
21130
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetw(&s_cversion,f,true))
21131 {
21132 return qe_invalid;
21133 }
21134
21135 //section size
21136
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&dummy_dword,f,true))
21137 {
21138 return qe_invalid;
21139 }
21140
21141 //finally... section data
21142
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetw(&item_drop_sets_to_read,f,true))
21143 {
21144 return qe_invalid;
21145 }
21146 96 }
21147 else
21148 {
21149 if(keepdata==true)
21150 {
21151 init_item_drop_sets();
21152 }
21153 }
21154
21155
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(s_version>=1)
21156 {
21157
2/2
✓ Branch 0 taken 1844 times.
✓ Branch 1 taken 96 times.
1940 for(int32_t i=0; i<item_drop_sets_to_read; i++)
21158 {
21159
1/2
✓ Branch 0 taken 1844 times.
✗ Branch 1 not taken.
1844 if(!pfread(tempitemdrop.name,sizeof(tempitemdrop.name),f,true))
21160 {
21161 return qe_invalid;
21162 }
21163
21164
2/2
✓ Branch 0 taken 18440 times.
✓ Branch 1 taken 1844 times.
20284 for(int32_t j=0; j<10; ++j)
21165 {
21166
1/2
✓ Branch 0 taken 18440 times.
✗ Branch 1 not taken.
18440 if(!p_igetw(&tempitemdrop.item[j],f,true))
21167 {
21168 return qe_invalid;
21169 }
21170 18440 }
21171
21172
2/2
✓ Branch 0 taken 20284 times.
✓ Branch 1 taken 1844 times.
22128 for(int32_t j=0; j<11; ++j)
21173 {
21174
1/2
✓ Branch 0 taken 20284 times.
✗ Branch 1 not taken.
20284 if(!p_igetw(&tempitemdrop.chance[j],f,true))
21175 {
21176 return qe_invalid;
21177 }
21178 20284 }
21179
21180 // Dec 2008: Addition of the 'Tall Grass' set, #12,
21181 // overrides the quest's set #12.
21182
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1844 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1844 if(s_version<2 && i==12)
21183 continue;
21184
21185 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
21186
1/4
✓ Branch 0 taken 1844 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1844 if(s_version<2) for(int32_t j=0; j<10; ++j)
21187 {
21188 int32_t it = tempitemdrop.item[j];
21189
21190 if((itemsbuf[it].family == itype_rupee
21191 && ((itemsbuf[it].amount)&0xFFF) == 10)
21192 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
21193 {
21194 tempitemdrop.chance[j+1]=0;
21195 }
21196 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
21197 {
21198 tempitemdrop.chance[j+1]=0;
21199 }
21200
21201 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
21202 if(itemsbuf[it].family == itype_misc)
21203 {
21204 // If a non-gameplay item was selected, then item drop was aborted.
21205 // Reflect this by increasing the 'Nothing' chance accordingly.
21206 tempitemdrop.chance[0]+=tempitemdrop.chance[j+1];
21207 tempitemdrop.chance[j+1]=0;
21208 }
21209 }
21210
21211
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1844 times.
1844 if(keepdata)
21212 {
21213 1844 memcpy(&item_drop_sets[i], &tempitemdrop, sizeof(item_drop_object));
21214 1844 }
21215 1844 }
21216 96 }
21217
21218 96 return 0;
21219 96 }
21220
21221 96 int32_t readfavorites(PACKFILE *f, int32_t, word, bool keepdata)
21222 {
21223 int32_t temp_num;
21224 dword dummy_dword;
21225 word num_favorite_combos;
21226 word num_favorite_combo_aliases;
21227 96 word s_version=0, s_cversion=0;
21228
21229 //section version info
21230
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_igetw(&s_version,f,true))
21231 {
21232 return qe_invalid;
21233 }
21234
21235 96 FFCore.quest_format[vFavourites] = s_version;
21236
21237
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetw(&s_cversion,f,true))
21238 {
21239 return qe_invalid;
21240 }
21241
21242 //section size
21243
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&dummy_dword,f,true))
21244 {
21245 return qe_invalid;
21246 }
21247
21248 //finally... section data
21249
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetw(&num_favorite_combos,f,true))
21250 {
21251 return qe_invalid;
21252 }
21253
21254
2/2
✓ Branch 0 taken 9600 times.
✓ Branch 1 taken 96 times.
9696 for(int32_t i=0; i<num_favorite_combos; i++)
21255 {
21256
1/2
✓ Branch 0 taken 9600 times.
✗ Branch 1 not taken.
9600 if(!p_igetl(&temp_num,f,true))
21257 {
21258 return qe_invalid;
21259 }
21260
21261
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9600 times.
9600 if(keepdata)
21262 {
21263 9600 favorite_combos[i]=temp_num;
21264 9600 }
21265 9600 }
21266
21267
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetw(&num_favorite_combo_aliases,f,true))
21268 {
21269 return qe_invalid;
21270 }
21271
21272
2/2
✓ Branch 0 taken 9600 times.
✓ Branch 1 taken 96 times.
9696 for(int32_t i=0; i<num_favorite_combo_aliases; i++)
21273 {
21274
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9600 times.
9600 if(!p_igetl(&temp_num,f,true))
21275 {
21276 return qe_invalid;
21277 }
21278
21279
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9600 times.
9600 if(keepdata)
21280 {
21281 9600 favorite_comboaliases[i]=temp_num;
21282 9600 }
21283 9600 }
21284
21285 96 return 0;
21286 96 }
21287
21288 /*
21289 switch (ret) {
21290 case 0:
21291 break;
21292
21293 case qe_invalid:
21294 goto invalid;
21295 break;
21296 default:
21297 pack_fclose(f);
21298 if(!oldquest)
21299 delete_file(tmpfilename);
21300 return ret;
21301 break;
21302 }
21303 */
21304
21305 const char *skip_text[skip_max]=
21306 {
21307 "skip_header", "skip_rules", "skip_strings", "skip_misc",
21308 "skip_tiles", "skip_combos", "skip_comboaliases", "skip_csets",
21309 "skip_maps", "skip_dmaps", "skip_doors", "skip_items",
21310 "skip_weapons", "skip_colors", "skip_icons", "skip_initdata",
21311 "skip_guys", "skip_herosprites", "skip_subscreens", "skip_ffscript",
21312 "skip_sfx", "skip_midis", "skip_cheats", "skip_itemdropsets",
21313 "skip_favorites"
21314 };
21315
21316
21317 void port250QuestRules(){
21318
21319 portCandleRules(); //Candle
21320 portBombRules();
21321
21322 }
21323
21324 void portCandleRules()
21325 {
21326 bool hurtshero = get_bit(quest_rules,qr_FIREPROOFHERO);
21327 //itemdata itemsbuf;
21328 for ( int32_t q = 0; q < MAXITEMS; q++ )
21329 {
21330 if ( itemsbuf[q].family == itype_candle )
21331 {
21332 if ( hurtshero ) itemsbuf[q].flags |= ITEM_FLAG2;
21333 else itemsbuf[q].flags &= ~ ITEM_FLAG2;
21334 }
21335 }
21336 }
21337
21338 void portBombRules()
21339 {
21340 bool hurtshero = get_bit(quest_rules,qr_OUCHBOMBS);
21341 //itemdata itemsbuf;
21342 for ( int32_t q = 0; q < MAXITEMS; q++ )
21343 {
21344 if ( itemsbuf[q].family == itype_bomb )
21345 {
21346 if ( hurtshero ) itemsbuf[q].flags |= ITEM_FLAG2;
21347 else itemsbuf[q].flags &= ~ ITEM_FLAG2;
21348 }
21349 }
21350
21351 }
21352
21353 //Internal function for loadquest wrapper
21354 99 int32_t _lq_int(const char *filename, zquestheader *Header, miscQdata *Misc, zctune *tunes, bool show_progress, bool compressed, bool encrypted, bool keepall, const byte *skip_flags, byte printmetadata)
21355 {
21356 99 DMapEditorLastMaptileUsed = 0;
21357 99 combosread=false;
21358 99 mapsread=false;
21359 99 fixffcs=false;
21360
21361
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if(get_debug()&&(key[KEY_LSHIFT]||key[KEY_RSHIFT]))
21362 {
21363 keepall=false;
21364 jwin_alert("Load Quest","Data retention disabled.",NULL,NULL,"OK",NULL,13,27,lfont);
21365 }
21366
21367 // show_progress=true;
21368 char tmpfilename[L_tmpnam];
21369 99 temp_name(tmpfilename);
21370 // char percent_done[30];
21371 99 bool catchup=false;
21372 byte tempbyte;
21373 99 word old_map_count=map_count;
21374
21375 99 byte old_quest_rules[QUESTRULES_NEW_SIZE] = {0};
21376 99 byte old_extra_rules[EXTRARULES_SIZE] = {0};
21377 99 byte old_midi_flags[MIDIFLAGS_SIZE] = {0};
21378
21379
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
99 if(keepall==false||get_bit(skip_flags, skip_rules))
21380 {
21381 memcpy(old_quest_rules, quest_rules, QUESTRULES_NEW_SIZE);
21382 memcpy(old_extra_rules, extra_rules, EXTRARULES_SIZE);
21383 }
21384
21385 99 memset(quest_rules, 0, QUESTRULES_NEW_SIZE); //clear here to prevent any kind of carryover -Z
21386 // memset(extra_rules, 0, EXTRARULES_SIZE); //clear here to prevent any kind of carryover -Z
21387
21388
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
99 if(keepall==false||get_bit(skip_flags, skip_midis))
21389 {
21390 memcpy(old_midi_flags, midi_flags, MIDIFLAGS_SIZE);
21391 }
21392
21393
21394
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
99 if(keepall&&!get_bit(skip_flags, skip_ffscript))
21395 {
21396 99 zScript.clear();
21397 99 globalmap.clear();
21398 99 genericmap.clear();
21399 99 ffcmap.clear();
21400 99 itemmap.clear();
21401 99 npcmap.clear();
21402 99 ewpnmap.clear();
21403 99 lwpnmap.clear();
21404 99 playermap.clear();
21405 99 dmapmap.clear();
21406 99 screenmap.clear();
21407 99 itemspritemap.clear();
21408 99 comboscriptmap.clear();
21409
21410
2/2
✓ Branch 0 taken 50589 times.
✓ Branch 1 taken 99 times.
50688 for(int32_t i=0; i<NUMSCRIPTFFC-1; i++)
21411 {
21412 50589 ffcmap[i].clear();
21413 50589 }
21414
21415 99 globalmap[0].slotname = "Slot 1:";
21416 99 globalmap[0].scriptname = "~Init";
21417 99 globalmap[0].update();
21418
21419
2/2
✓ Branch 0 taken 693 times.
✓ Branch 1 taken 99 times.
792 for(int32_t i=1; i<NUMSCRIPTGLOBAL; i++)
21420 {
21421 693 globalmap[i].clear();
21422 693 }
21423
21424
2/2
✓ Branch 0 taken 25245 times.
✓ Branch 1 taken 99 times.
25344 for(int32_t i=0; i<NUMSCRIPTITEM-1; i++)
21425 {
21426 25245 itemmap[i].clear();
21427 25245 }
21428
21429 //new script types -- prevent carrying over to a quest that you load after reading them
21430 //e.g., a quest has an npc script, and you make a blank quest, that now believes that it has an npc script, too!
21431
2/2
✓ Branch 0 taken 25245 times.
✓ Branch 1 taken 99 times.
25344 for(int32_t i=0; i<NUMSCRIPTGUYS-1; i++)
21432 {
21433 25245 npcmap[i].clear();
21434 25245 }
21435
2/2
✓ Branch 0 taken 25245 times.
✓ Branch 1 taken 99 times.
25344 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21436 {
21437 25245 lwpnmap[i].clear();
21438 25245 }
21439
2/2
✓ Branch 0 taken 25245 times.
✓ Branch 1 taken 99 times.
25344 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21440 {
21441 25245 ewpnmap[i].clear();
21442 25245 }
21443
2/2
✓ Branch 0 taken 396 times.
✓ Branch 1 taken 99 times.
495 for(int32_t i=0; i<NUMSCRIPTPLAYER-1; i++)
21444 {
21445 396 playermap[i].clear();
21446 396 }
21447
2/2
✓ Branch 0 taken 25245 times.
✓ Branch 1 taken 99 times.
25344 for(int32_t i=0; i<NUMSCRIPTSDMAP-1; i++)
21448 {
21449 25245 dmapmap[i].clear();
21450 25245 }
21451
2/2
✓ Branch 0 taken 25245 times.
✓ Branch 1 taken 99 times.
25344 for(int32_t i=0; i<NUMSCRIPTSCREEN-1; i++)
21452 {
21453 25245 screenmap[i].clear();
21454 25245 }
21455
2/2
✓ Branch 0 taken 25245 times.
✓ Branch 1 taken 99 times.
25344 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE-1; i++)
21456 {
21457 25245 itemspritemap[i].clear();
21458 25245 }
21459
2/2
✓ Branch 0 taken 50589 times.
✓ Branch 1 taken 99 times.
50688 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA-1; i++)
21460 {
21461 50589 comboscriptmap[i].clear();
21462 50589 }
21463
2/2
✓ Branch 0 taken 50589 times.
✓ Branch 1 taken 99 times.
50688 for(int32_t i=0; i<NUMSCRIPTSGENERIC-1; i++)
21464 {
21465 50589 genericmap[i].clear();
21466 50589 }
21467
21468 99 reset_scripts();
21469 99 }
21470
21471 zquestheader tempheader;
21472 99 memset(&tempheader, 0, sizeof(zquestheader));
21473 99 zinfo tempzi;
21474 99 tempzi.clear();
21475 99 load_tmp_zi = &tempzi;
21476
21477 // oldquest flag is set when an unencrypted qst file is suspected.
21478 99 bool oldquest = false;
21479 99 int32_t open_error=0;
21480 char deletefilename[1024];
21481 99 PACKFILE *f=open_quest_file(&open_error, filename, deletefilename, compressed, encrypted, show_progress);
21482
21483
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(!f)
21484 return open_error;
21485 char zinfofilename[2048];
21486 99 replace_extension(zinfofilename, filename, "zinfo", 2047);
21487 99 int32_t ret=0;
21488
21489 //header
21490 99 box_out("Reading Header...");
21491 99 ret=readheader(f, &tempheader, true, printmetadata);
21492
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
99 checkstatus(ret);
21493 99 box_out("okay.");
21494 99 box_eol();
21495
21496
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 22 times.
99 if(read_zinfo)
21497 {
21498 22 box_out("Reading ZInfo - ");
21499
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 21 times.
22 box_out(read_ext_zinfo ? "External..." : "Internal...");
21500
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 21 times.
22 if(read_ext_zinfo)
21501 {
21502 1 PACKFILE *inf=pack_fopen_password(zinfofilename, F_READ, "");
21503 1 ret=readzinfo(inf, tempzi, tempheader);
21504
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(inf) pack_fclose(inf);
21505
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
1 checkstatus(ret);
21506 1 }
21507 else
21508 {
21509 21 ret=readzinfo(f, tempzi, tempheader);
21510
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
21 checkstatus(ret);
21511 }
21512 22 box_out("okay.");
21513 22 box_eol();
21514 22 }
21515
21516
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(tempheader.zelda_version>=0x193)
21517 {
21518 dword section_id;
21519
21520 //section id
21521
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_mgetl(&section_id,f,true))
21522 {
21523 return qe_invalid;
21524 }
21525
21526
2/2
✓ Branch 0 taken 2349 times.
✓ Branch 1 taken 99 times.
2448 while(!pack_feof(f))
21527 {
21528
24/25
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
✓ Branch 2 taken 99 times.
✓ Branch 3 taken 99 times.
✓ Branch 4 taken 99 times.
✓ Branch 5 taken 99 times.
✓ Branch 6 taken 96 times.
✓ Branch 7 taken 99 times.
✓ Branch 8 taken 99 times.
✓ Branch 9 taken 99 times.
✓ Branch 10 taken 99 times.
✓ Branch 11 taken 99 times.
✓ Branch 12 taken 99 times.
✓ Branch 13 taken 96 times.
✓ Branch 14 taken 96 times.
✓ Branch 15 taken 99 times.
✓ Branch 16 taken 99 times.
✓ Branch 17 taken 96 times.
✓ Branch 18 taken 96 times.
✓ Branch 19 taken 96 times.
✓ Branch 20 taken 96 times.
✓ Branch 21 taken 99 times.
✓ Branch 22 taken 99 times.
✓ Branch 23 taken 96 times.
✓ Branch 24 taken 96 times.
2349 switch(section_id)
21529 {
21530 case ID_RULES:
21531
21532 //rules
21533
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(catchup)
21534 {
21535 box_out("found.");
21536 box_eol();
21537 catchup=false;
21538 }
21539
21540 99 box_out("Reading Rules...");
21541
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ret=readrules(f, &tempheader, keepall&&!get_bit(skip_flags, skip_rules));
21542
1/5
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
99 checkstatus(ret);
21543 99 box_out("okay.");
21544 99 box_eol();
21545 99 break;
21546
21547 case ID_STRINGS:
21548
21549 //strings
21550
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(catchup)
21551 {
21552 box_out("found.");
21553 box_eol();
21554 catchup=false;
21555 }
21556
21557 99 box_out("Reading Strings...");
21558
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ret=readstrings(f, &tempheader, keepall&&!get_bit(skip_flags, skip_strings));
21559
1/5
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
99 checkstatus(ret);
21560 99 box_out("okay.");
21561 99 box_eol();
21562 99 break;
21563
21564 case ID_MISC:
21565
21566 //misc data
21567
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(catchup)
21568 {
21569 box_out("found.");
21570 box_eol();
21571 catchup=false;
21572 }
21573
21574 99 box_out("Reading Misc. Data...");
21575
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ret=readmisc(f, &tempheader, Misc, keepall&&!get_bit(skip_flags, skip_misc));
21576
1/5
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
99 checkstatus(ret);
21577 99 box_out("okay.");
21578 99 box_eol();
21579 99 break;
21580
21581 case ID_TILES:
21582
21583 //tiles
21584
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(catchup)
21585 {
21586 box_out("found.");
21587 box_eol();
21588 catchup=false;
21589 }
21590
21591 99 box_out("Reading Tiles...");
21592
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ret=readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false, keepall&&!get_bit(skip_flags, skip_tiles));
21593
1/5
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
99 checkstatus(ret);
21594 99 box_out("okay.");
21595 99 box_eol();
21596 99 break;
21597
21598 case ID_COMBOS:
21599
21600 //combos
21601
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(catchup)
21602 {
21603 box_out("found.");
21604 box_eol();
21605 catchup=false;
21606 }
21607
21608 99 box_out("Reading Combos...");
21609
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ret=readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS, keepall&&!get_bit(skip_flags, skip_combos));
21610 99 combosread=true;
21611
1/5
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
99 checkstatus(ret);
21612 99 box_out("okay.");
21613 99 box_eol();
21614 99 break;
21615
21616 case ID_COMBOALIASES:
21617
21618 //combo aliases
21619
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(catchup)
21620 {
21621 box_out("found.");
21622 box_eol();
21623 catchup=false;
21624 }
21625
21626 96 box_out("Reading Combo Aliases...");
21627
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 ret=readcomboaliases(f, &tempheader, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_comboaliases));
21628
1/5
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
96 checkstatus(ret);
21629 96 box_out("okay.");
21630 96 box_eol();
21631 96 break;
21632
21633 case ID_CSETS:
21634
21635 //color data
21636
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(catchup)
21637 {
21638 box_out("found.");
21639 box_eol();
21640 catchup=false;
21641 }
21642
21643 99 box_out("Reading Color Data...");
21644
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ret=readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL, keepall&&!get_bit(skip_flags, skip_csets));
21645
1/5
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
99 checkstatus(ret);
21646 99 box_out("okay.");
21647 99 box_eol();
21648 99 break;
21649
21650 case ID_MAPS:
21651
21652 //maps
21653
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(catchup)
21654 {
21655 box_out("found.");
21656 box_eol();
21657 catchup=false;
21658 }
21659
21660 99 box_out("Reading Maps...");
21661
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ret=readmaps(f, &tempheader, keepall&&!get_bit(skip_flags, skip_maps));
21662 99 mapsread=true;
21663
1/5
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
99 checkstatus(ret);
21664 99 box_out("okay.");
21665 99 box_eol();
21666 99 break;
21667
21668 case ID_DMAPS:
21669
21670 //dmaps
21671
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(catchup)
21672 {
21673 box_out("found.");
21674 box_eol();
21675 catchup=false;
21676 }
21677
21678 99 box_out("Reading DMaps...");
21679
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ret=readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS, keepall&&!get_bit(skip_flags, skip_dmaps));
21680
1/5
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
99 checkstatus(ret);
21681 99 box_out("okay.");
21682 99 box_eol();
21683 99 break;
21684
21685 case ID_DOORS:
21686
21687 //door combo sets
21688
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(catchup)
21689 {
21690 box_out("found.");
21691 box_eol();
21692 catchup=false;
21693 }
21694
21695 99 box_out("Reading Doors...");
21696
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ret=readdoorcombosets(f, &tempheader, keepall&&!get_bit(skip_flags, skip_doors));
21697
1/5
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
99 checkstatus(ret);
21698 99 box_out("okay.");
21699 99 box_eol();
21700 99 break;
21701
21702 case ID_ITEMS:
21703
21704 //items
21705
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(catchup)
21706 {
21707 box_out("found.");
21708 box_eol();
21709 catchup=false;
21710 }
21711
21712 99 box_out("Reading Items...");
21713
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ret=readitems(f, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_items));
21714
1/5
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
99 checkstatus(ret);
21715
21716 99 box_out("okay.");
21717 99 box_eol();
21718 99 break;
21719
21720 case ID_WEAPONS:
21721
21722 //weapons
21723
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(catchup)
21724 {
21725 box_out("found.");
21726 box_eol();
21727 catchup=false;
21728 }
21729
21730 99 box_out("Reading Weapons...");
21731
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ret=readweapons(f, &tempheader, keepall&&!get_bit(skip_flags, skip_weapons));
21732
1/5
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
99 checkstatus(ret);
21733 99 box_out("okay.");
21734 99 box_eol();
21735 99 break;
21736
21737 case ID_COLORS:
21738
21739 //misc. colors
21740
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(catchup)
21741 {
21742 box_out("found.");
21743 box_eol();
21744 catchup=false;
21745 }
21746
21747 96 box_out("Reading Misc. Colors...");
21748
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 ret=readmisccolors(f, &tempheader, Misc, keepall&&!get_bit(skip_flags, skip_colors));
21749
1/5
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
96 checkstatus(ret);
21750 96 box_out("okay.");
21751 96 box_eol();
21752 96 break;
21753
21754 case ID_ICONS:
21755
21756 //game icons
21757
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(catchup)
21758 {
21759 box_out("found.");
21760 box_eol();
21761 catchup=false;
21762 }
21763
21764 96 box_out("Reading Game Icons...");
21765
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 ret=readgameicons(f, &tempheader, Misc, keepall&&!get_bit(skip_flags, skip_icons));
21766
1/5
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
96 checkstatus(ret);
21767 96 box_out("okay.");
21768 96 box_eol();
21769 96 break;
21770
21771 case ID_INITDATA:
21772
21773 //initialization data
21774
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(catchup)
21775 {
21776 box_out("found.");
21777 box_eol();
21778 catchup=false;
21779 }
21780
21781 99 box_out("Reading Init. Data...");
21782
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ret=readinitdata(f, &tempheader, keepall&&!get_bit(skip_flags, skip_initdata));
21783
1/5
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
99 checkstatus(ret);
21784 99 box_out("okay.");
21785 99 box_eol();
21786
21787
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
99 if(keepall&&!get_bit(skip_flags, skip_subscreens))
21788 {
21789
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 16 times.
99 if(zinit.subscreen!=ssdtMAX) //not using custom subscreens
21790 {
21791 16 setupsubscreens();
21792
21793
2/2
✓ Branch 0 taken 8192 times.
✓ Branch 1 taken 16 times.
8208 for(int32_t i=0; i<MAXDMAPS; ++i)
21794 {
21795 8192 int32_t type=DMaps[i].type&dmfTYPE;
21796
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 8131 times.
8192 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
21797 8192 DMaps[i].passive_subscreen=(get_bit(quest_rules,qr_ENABLEMAGIC))?0:1;
21798 8192 }
21799 16 }
21800 99 }
21801
21802
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
99 if(keepall&&!get_bit(skip_flags, skip_sfx))
21803 {
21804 99 setupsfx();
21805 99 }
21806
21807
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
99 if(keepall&&!get_bit(skip_flags, skip_itemdropsets))
21808 {
21809 99 init_item_drop_sets();
21810 99 }
21811
21812
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
99 if(keepall&&!get_bit(skip_flags, skip_favorites))
21813 {
21814 99 init_favorites();
21815 99 }
21816
21817 99 break;
21818
21819 case ID_GUYS:
21820
21821 //guys
21822
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(catchup)
21823 {
21824 box_out("found.");
21825 box_eol();
21826 catchup=false;
21827 }
21828
21829 99 box_out("Reading Custom Guy Data...");
21830
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ret=readguys(f, &tempheader, keepall&&!get_bit(skip_flags, skip_guys));
21831
1/5
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
99 checkstatus(ret);
21832 99 box_out("okay.");
21833 99 box_eol();
21834 99 break;
21835
21836 case ID_HEROSPRITES:
21837
21838 //player sprites
21839
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(catchup)
21840 {
21841 box_out("found.");
21842 box_eol();
21843 catchup=false;
21844 }
21845
21846 96 box_out("Reading Custom Player Sprite Data...");
21847
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 ret=readherosprites(f, &tempheader, keepall&&!get_bit(skip_flags, skip_herosprites));
21848
1/5
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
96 checkstatus(ret);
21849 96 box_out("okay.");
21850 96 box_eol();
21851 96 break;
21852
21853 case ID_SUBSCREEN:
21854
21855 //custom subscreens
21856
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(catchup)
21857 {
21858 box_out("found.");
21859 box_eol();
21860 catchup=false;
21861 }
21862
21863 96 box_out("Reading Custom Subscreen Data...");
21864
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 ret=readsubscreens(f, &tempheader, keepall&&!get_bit(skip_flags, skip_subscreens));
21865
1/5
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
96 checkstatus(ret);
21866 96 box_out("okay.");
21867 96 box_eol();
21868 96 break;
21869
21870 case ID_FFSCRIPT:
21871
21872 //Freeform combo scripts
21873
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(catchup)
21874 {
21875 box_out("found.");
21876 box_eol();
21877 catchup=false;
21878 }
21879
21880 96 box_out("Reading FF Script Data...");
21881
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 ret=readffscript(f, &tempheader, keepall&&!get_bit(skip_flags, skip_ffscript));
21882
1/5
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
96 checkstatus(ret);
21883 96 box_out("okay.");
21884 96 box_eol();
21885 96 break;
21886
21887 case ID_SFX:
21888
21889 //SFX data
21890
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(catchup)
21891 {
21892 box_out("found.");
21893 box_eol();
21894 catchup=false;
21895 }
21896
21897 96 box_out("Reading SFX Data...");
21898
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 ret=readsfx(f, &tempheader, keepall&&!get_bit(skip_flags, skip_sfx));
21899
1/5
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
96 checkstatus(ret);
21900 96 box_out("okay.");
21901 96 box_eol();
21902 96 break;
21903
21904 case ID_MIDIS:
21905
21906 //midis
21907
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(catchup)
21908 {
21909 box_out("found.");
21910 box_eol();
21911 catchup=false;
21912 }
21913
21914 99 box_out("Reading Tunes...");
21915
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ret=readtunes(f, &tempheader, tunes, keepall&&!get_bit(skip_flags, skip_midis));
21916
1/5
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
99 checkstatus(ret);
21917 99 box_out("okay.");
21918 99 box_eol();
21919 99 break;
21920
21921 case ID_CHEATS:
21922
21923 //cheat codes
21924
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(catchup)
21925 {
21926 box_out("found.");
21927 box_eol();
21928 catchup=false;
21929 }
21930
21931 99 box_out("Reading Cheat Codes...");
21932
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ret=readcheatcodes(f, &tempheader, keepall&&!get_bit(skip_flags, skip_cheats));
21933
1/5
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
99 checkstatus(ret);
21934 99 box_out("okay.");
21935 99 box_eol();
21936 99 break;
21937
21938 case ID_ITEMDROPSETS:
21939
21940 //item drop sets
21941
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(catchup)
21942 {
21943 box_out("found.");
21944 box_eol();
21945 catchup=false;
21946 }
21947
21948 96 box_out("Reading Item Drop Sets...");
21949
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 ret=readitemdropsets(f, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_itemdropsets));
21950
1/5
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
96 checkstatus(ret);
21951 96 box_out("okay.");
21952 96 box_eol();
21953 96 break;
21954
21955 case ID_FAVORITES:
21956
21957 //favorite combos and combo aliases
21958
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(catchup)
21959 {
21960 box_out("found.");
21961 box_eol();
21962 catchup=false;
21963 }
21964
21965 96 box_out("Reading Favorite Combos...");
21966
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 ret=readfavorites(f, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_favorites));
21967
1/5
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
96 checkstatus(ret);
21968 96 box_out("okay.");
21969 96 box_eol();
21970 96 break;
21971
21972 default:
21973 if(!catchup)
21974 {
21975 box_out("Bad token! Searching...");
21976 box_eol();
21977 }
21978
21979 catchup=true;
21980 break;
21981 }
21982
21983
21984
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2349 times.
2349 if(catchup)
21985 {
21986 //section id
21987 section_id=(section_id<<8);
21988
21989 if(!p_getc(&tempbyte,f,true))
21990 {
21991 return qe_invalid;
21992 }
21993
21994 section_id+=tempbyte;
21995 }
21996
21997 else
21998 {
21999 //section id
22000
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 2250 times.
2349 if(!pack_feof(f))
22001 {
22002
1/2
✓ Branch 0 taken 2250 times.
✗ Branch 1 not taken.
2250 if(!p_mgetl(&section_id,f,true))
22003 {
22004 return qe_invalid;
22005 }
22006 2250 }
22007 }
22008 }
22009 99 }
22010 else
22011 {
22012 //rules
22013 box_out("Reading Rules...");
22014 ret=readrules(f, &tempheader, keepall&&!get_bit(skip_flags, skip_rules));
22015 checkstatus(ret);
22016 box_out("okay.");
22017 box_eol();
22018
22019 //strings
22020 box_out("Reading Strings...");
22021 ret=readstrings(f, &tempheader, keepall&&!get_bit(skip_flags, skip_strings));
22022 checkstatus(ret);
22023 box_out("okay.");
22024 box_eol();
22025
22026 //door combo sets
22027 box_out("Reading Doors...");
22028 ret=readdoorcombosets(f, &tempheader, keepall&&!get_bit(skip_flags, skip_doors));
22029 checkstatus(ret);
22030 box_out("okay.");
22031 box_eol();
22032
22033 //dmaps
22034 box_out("Reading DMaps...");
22035 ret=readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS, keepall&&!get_bit(skip_flags, skip_dmaps));
22036 checkstatus(ret);
22037 box_out("okay.");
22038 box_eol();
22039
22040 // misc data
22041 box_out("Reading Misc. Data...");
22042 ret=readmisc(f, &tempheader, Misc, keepall&&!get_bit(skip_flags, skip_misc));
22043 checkstatus(ret);
22044 box_out("okay.");
22045 box_eol();
22046
22047 //items
22048 box_out("Reading Items...");
22049 ret=readitems(f, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_items));
22050 checkstatus(ret);
22051 box_out("okay.");
22052 box_eol();
22053
22054 //weapons
22055 box_out("Reading Weapons...");
22056 ret=readweapons(f, &tempheader, keepall&&!get_bit(skip_flags, skip_weapons));
22057 checkstatus(ret);
22058 box_out("okay.");
22059 box_eol();
22060
22061 //guys
22062 box_out("Reading Custom Guy Data...");
22063 ret=readguys(f, &tempheader, keepall&&!get_bit(skip_flags, skip_guys));
22064 checkstatus(ret);
22065 box_out("okay.");
22066 box_eol();
22067
22068 //maps
22069 box_out("Reading Maps...");
22070 ret=readmaps(f, &tempheader, keepall&&!get_bit(skip_flags, skip_maps));
22071 mapsread=true;
22072 checkstatus(ret);
22073 box_out("okay.");
22074 box_eol();
22075
22076 //combos
22077 box_out("Reading Combos...");
22078 ret=readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS, keepall&&!get_bit(skip_flags, skip_combos));
22079 combosread=true;
22080 checkstatus(ret);
22081 box_out("okay.");
22082 box_eol();
22083
22084 //color data
22085 box_out("Reading Color Data...");
22086 ret=readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL, keepall&&!get_bit(skip_flags, skip_csets));
22087 checkstatus(ret);
22088 box_out("okay.");
22089 box_eol();
22090
22091 //tiles
22092 box_out("Reading Tiles...");
22093 ret=readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false, keepall&&!get_bit(skip_flags, skip_tiles));
22094 checkstatus(ret);
22095 box_out("okay.");
22096 box_eol();
22097
22098 //midis
22099 box_out("Reading Tunes...");
22100 ret=readtunes(f, &tempheader, tunes, keepall&&!get_bit(skip_flags, skip_midis));
22101 checkstatus(ret);
22102 box_out("okay.");
22103 box_eol();
22104
22105 //cheat codes
22106 box_out("Reading Cheat Codes...");
22107 ret=readcheatcodes(f, &tempheader, keepall&&!get_bit(skip_flags, skip_cheats));
22108 checkstatus(ret);
22109 box_out("okay.");
22110 box_eol();
22111
22112 //initialization data
22113 box_out("Reading Init. Data...");
22114 ret=readinitdata(f, &tempheader, keepall&&!get_bit(skip_flags, skip_initdata));
22115 checkstatus(ret);
22116 box_out("okay.");
22117 box_eol();
22118
22119 if(keepall&&!get_bit(skip_flags, skip_subscreens))
22120 {
22121 setupsubscreens();
22122
22123 for(int32_t i=0; i<MAXDMAPS; ++i)
22124 {
22125 int32_t type=DMaps[i].type&dmfTYPE;
22126 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
22127 DMaps[i].passive_subscreen=(get_bit(quest_rules,qr_ENABLEMAGIC))?0:1;
22128 }
22129 }
22130
22131 box_out("Setting Up Default Sound Effects...");
22132
22133 if(keepall&&!get_bit(skip_flags, skip_sfx))
22134 setupsfx();
22135
22136 box_out("okay.");
22137 box_eol();
22138
22139 //player sprites
22140 box_out("Reading Custom Player Sprite Data...");
22141 ret=readherosprites2(f, -1, 0, keepall&&!get_bit(skip_flags, skip_herosprites));
22142 checkstatus(ret);
22143 box_out("okay.");
22144 box_eol();
22145
22146 box_out("Setting Up Default Item Drop Sets...");
22147 ret=readitemdropsets(f, -1, 0, keepall&&!get_bit(skip_flags, skip_itemdropsets));
22148 box_out("okay.");
22149 box_eol();
22150 }
22151
22152 99 init_spritelists();
22153
22154 // check data
22155
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(f)
22156 {
22157 99 pack_fclose(f);
22158 99 }
22159
22160
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(!oldquest)
22161 {
22162
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(exists(tmpfilename))
22163 {
22164 delete_file(tmpfilename);
22165 }
22166 99 }
22167
22168
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if(fixffcs && combosread && mapsread)
22169 {
22170 for(int32_t i=0; i<map_count; i++)
22171 {
22172 for(int32_t j=0; j<MAPSCRS; j++)
22173 {
22174 for(int32_t m=0; m<32; m++)
22175 {
22176 if(combobuf[TheMaps[(i*MAPSCRS)+j].ffcs[m].getData()].type == cCHANGE)
22177 TheMaps[(i*MAPSCRS)+j].ffcs[m].flags|=ffCHANGER;
22178 }
22179 }
22180 }
22181 }
22182
22183
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 18 times.
99 if(get_bit(quest_rules, qr_CONTFULL_DEP))
22184 {
22185 18 set_bit(quest_rules, qr_CONTFULL_DEP, 0);
22186 18 set_bit(zinit.misc, idM_CONTPERCENT, 1);
22187 18 zinit.cont_heart=100;
22188 18 zinit.start_heart=zinit.hc;
22189 18 }
22190
22191 99 box_out("Done.");
22192 99 box_eol();
22193 99 box_end(false);
22194
22195 // if (keepall==true||!get_bit(skip_flags, skip_header))
22196
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
99 if(keepall&&!get_bit(skip_flags, skip_header))
22197 {
22198 99 memcpy(Header, &tempheader, sizeof(tempheader));
22199 99 }
22200
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
99 if(keepall&&!get_bit(skip_flags, skip_zinfo))
22201 {
22202 99 ZI.copyFrom(tempzi);
22203 99 }
22204
22205
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
99 if(!keepall||get_bit(skip_flags, skip_maps))
22206 {
22207 map_count=old_map_count;
22208 }
22209
22210
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
99 if(!keepall||get_bit(skip_flags, skip_rules))
22211 {
22212 memcpy(quest_rules, old_quest_rules, QUESTRULES_NEW_SIZE);
22213 memcpy(extra_rules, old_extra_rules, EXTRARULES_SIZE);
22214 }
22215
22216
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
99 if(!keepall||get_bit(skip_flags, skip_midis))
22217 {
22218 memcpy(midi_flags, old_midi_flags, MIDIFLAGS_SIZE);
22219 }
22220
22221
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(deletefilename[0] && exists(deletefilename))
22222 {
22223 99 delete_file(deletefilename);
22224 99 }
22225
22226 //Debug FFCore.quest_format[]
22227 99 al_trace("Quest made in ZC Version: %x\n", FFCore.quest_format[vZelda]);
22228 99 al_trace("Quest made in ZC Build: %d\n", FFCore.quest_format[vBuild]);
22229 99 al_trace("Quest Section 'Header' is Version: %d\n", FFCore.quest_format[vHeader]);
22230 99 al_trace("Quest Section 'Rules' is Version: %d\n", FFCore.quest_format[vRules]);
22231 99 al_trace("Quest Section 'Strings' is Version: %d\n", FFCore.quest_format[vStrings]);
22232 99 al_trace("Quest Section 'Misc' is Version: %d\n", FFCore.quest_format[vMisc]);
22233 99 al_trace("Quest Section 'Tiles' is Version: %d\n", FFCore.quest_format[vTiles]);
22234 99 al_trace("Quest Section 'Combos' is Version: %d\n", FFCore.quest_format[vCombos]);
22235 99 al_trace("Quest Section 'CSets' is Version: %d\n", FFCore.quest_format[vCSets]);
22236 99 al_trace("Quest Section 'Maps' is Version: %d\n", FFCore.quest_format[vMaps]);
22237 99 al_trace("Quest Section 'DMaps' is Version: %d\n", FFCore.quest_format[vDMaps]);
22238 99 al_trace("Quest Section 'Doors' is Version: %d\n", FFCore.quest_format[vDoors]);
22239 99 al_trace("Quest Section 'Items' is Version: %d\n", FFCore.quest_format[vItems]);
22240 99 al_trace("Quest Section 'Weapons' is Version: %d\n", FFCore.quest_format[vWeaponSprites]);
22241 99 al_trace("Quest Section 'Colors' is Version: %d\n", FFCore.quest_format[vColours]);
22242 99 al_trace("Quest Section 'Icons' is Version: %d\n", FFCore.quest_format[vIcons]);
22243 //al_trace("Quest Section 'Gfx Pack' is Version: %d; qst.cpp doesn't read this!\n", FFCore.quest_format[vGfxPack]);
22244 99 al_trace("Quest Section 'InitData' is Version: %d\n", FFCore.quest_format[vInitData]);
22245 99 al_trace("Quest Section 'Guys' is Version: %d\n", FFCore.quest_format[vGuys]);
22246 99 al_trace("Quest Section 'MIDIs' is Version: %d\n", FFCore.quest_format[vMIDIs]);
22247 99 al_trace("Quest Section 'Cheats' is Version: %d\n", FFCore.quest_format[vCheats]);
22248 //al_trace("Quest Section 'Save Format' is Version: %d; qst.cpp doesn't read this!\n", FFCore.quest_format[vSaveformat]);
22249 99 al_trace("Quest Section 'Combo Aliases' is Version: %d\n", FFCore.quest_format[vComboAliases]);
22250 99 al_trace("Quest Section 'Player Sprites' is Version: %d\n", FFCore.quest_format[vHeroSprites]);
22251 99 al_trace("Quest Section 'Subscreen' is Version: %d\n", FFCore.quest_format[vSubscreen]);
22252 99 al_trace("Quest Section 'Dropsets' is Version: %d\n", FFCore.quest_format[vItemDropsets]);
22253 99 al_trace("Quest Section 'FFScript' is Version: %d\n", FFCore.quest_format[vFFScript]);
22254 99 al_trace("Quest Section 'SFX' is Version: %d\n", FFCore.quest_format[vSFX]);
22255 99 al_trace("Quest Section 'Favorites' is Version: %d\n", FFCore.quest_format[vFavourites]);
22256 99 al_trace("Quest Section 'CompatRules' is Version: %d\n", FFCore.quest_format[vCompatRule]);
22257 //Print metadata for versions under 2.10 here. Bleah.
22258
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if( FFCore.quest_format[vZelda] < 0x210 )
22259 {
22260 zprint2("\n[ZQUEST CREATOR METADATA]\n");
22261
22262 switch(FFCore.quest_format[vZelda])
22263 {
22264 case 0x193:
22265 {
22266 zprint2("Last saved in ZC Editor Version: 1.93, Beta %d\n", FFCore.quest_format[vBuild]); break;
22267 }
22268 case 0x192:
22269 {
22270 zprint2("Last saved in ZC Editor Version: 1.92, Beta %d\n", FFCore.quest_format[vBuild]); break;
22271 }
22272 case 0x190:
22273 {
22274 zprint2("Last saved in ZC Editor Version: 1.90");
22275 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22276 else zprint2("\n");
22277 break;
22278 }
22279 case 0x188:
22280 {
22281 zprint2("Last saved in ZC Editor Version: 1.88");
22282 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22283 else zprint2("\n");
22284 break;
22285 }
22286 case 0x187:
22287 {
22288 zprint2("Last saved in ZC Editor Version: 1.87");
22289 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22290 else zprint2("\n");
22291 break;
22292 }
22293 case 0x186:
22294 {
22295 zprint2("Last saved in ZC Editor Version: 1.86");
22296 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22297 else zprint2("\n");
22298 break;
22299 }
22300 case 0x185:
22301 {
22302 zprint2("Last saved in ZC Editor Version: 1.85");
22303 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22304 else zprint2("\n");
22305 break;
22306 }
22307 case 0x184:
22308 {
22309 zprint2("Last saved in ZC Editor Version: 1.84");
22310 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22311 else zprint2("\n");
22312 break;
22313 }
22314 case 0x183:
22315 {
22316 zprint2("Last saved in ZC Editor Version: 1.83");
22317 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22318 else zprint2("\n");
22319 break;
22320 }
22321 case 0x182:
22322 {
22323 zprint2("Last saved in ZC Editor Version: 1.82");
22324 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22325 else zprint2("\n");
22326 break;
22327 }
22328 case 0x181:
22329 {
22330 zprint2("Last saved in ZC Editor Version: 1.81");
22331 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22332 else zprint2("\n");
22333 break;
22334 }
22335 case 0x180:
22336 {
22337 zprint2("Last saved in ZC Editor Version: 1.80");
22338 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22339 else zprint2("\n");
22340 break;
22341 }
22342 default:
22343 {
22344 zprint2("Last saved in ZC Editor Version: %x, Beta %d\n", FFCore.quest_format[vZelda],FFCore.quest_format[vBuild]); break;
22345 }
22346 }
22347 }
22348
22349 99 return qe_OK;
22350
22351 invalid:
22352 box_out("error.");
22353 box_eol();
22354 box_end(true);
22355
22356 if(f)
22357 {
22358 pack_fclose(f);
22359 }
22360
22361 if(!oldquest)
22362 {
22363 if(exists(tmpfilename))
22364 {
22365 delete_file(tmpfilename);
22366 }
22367
22368 if(deletefilename[0] && exists(deletefilename))
22369 {
22370 delete_file(deletefilename);
22371 }
22372 }
22373
22374 return qe_invalid;
22375
22376 99 }
22377
22378 99 int32_t loadquest(const char *filename, zquestheader *Header, miscQdata *Misc, zctune *tunes, bool show_progress, bool compressed, bool encrypted, bool keepall, byte *skip_flags, byte printmetadata, bool report, byte qst_num)
22379 {
22380 99 loading_qst_name = filename;
22381 99 loading_qst_num = qst_num;
22382 // In CI, builds are cached for replay tests, which can result in their build dates being earlier than what it would be locally.
22383 // So to avoid a more-recently update .qst file from hitting the "last saved in a newer version" prompt, we disable for replaying.
22384
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if (!replay_is_replaying())
22385 loadquest_report = report;
22386 99 int32_t ret = _lq_int(filename, Header, Misc, tunes, show_progress, compressed, encrypted, keepall, skip_flags,printmetadata);
22387 99 load_tmp_zi = NULL;
22388 99 loading_qst_name = NULL;
22389 99 loadquest_report = false;
22390 99 loading_qst_num = 0;
22391 99 return ret;
22392 }
22393 /*** end of qst.cc ***/
22394
22395